Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ node_js:
- "4"

cache:
yarn: true
directories:
- node_modules
- $HOME/.npm
- $HOME/.cache

before_install:
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
- npm config set spin false
- npm install -g bower
# Since we override the install hooks, we need to setup Yarn on our own
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add bower
- bower --version

install:
- yarn install --no-lockfile

script:
- yarn test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ The following options exist:
| emberDataVersion | Set the version of ember-data, as you would in your `package.json` | emberjs/data#master |
| fixturesPath | The path to look for your fixture files (see below) | test/fixtures |
| noFixtures | Disables the use of fixture files | false |
| yarn | Use yarn instead of npm | false |


### Fixtures
Expand Down
11 changes: 5 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ init:
# Install scripts. (runs after repo cloning)
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm i -g npm@^3
- npm config set spin false
- npm install -g bower
- npm install
- yarn global add bower
- yarn install

# Post-install test scripts.
test_script:
- node --version
- npm --version
- yarn --version
- bower --version
- npm test
- yarn test

cache:
- '%APPDATA%\npm-cache'
- "%LOCALAPPDATA%\\Yarn"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental double slash?


# Don't actually build.
build: off
24 changes: 19 additions & 5 deletions lib/utilities/pristine.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function installPristineApp(appName, options) {
chdir(temp.pristinePath);

// Install a vanilla app and cd into it
let args = generateArgsForEmberNew(hasNodeModules, hasBowerComponents);
let args = generateArgsForEmberNew(hasNodeModules, hasBowerComponents, options);
let promise = runNew(appName, args)
.catch(handleResult)
.then(() => chdir(path.join(temp.pristinePath, appName)));
Expand All @@ -91,7 +91,8 @@ function installPristineApp(appName, options) {
hasNodeModules,
hasBowerComponents,
emberVersion: options.emberVersion || 'canary',
emberDataVersion: options.emberDataVersion || 'emberjs/data#master'
emberDataVersion: options.emberDataVersion || 'emberjs/data#master',
yarn: options.yarn || false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am asking myself if it could make sense to not default to false, but instead check if the addon has a yarn.lock file, and default to true in this case? ember new needs the --yarn option to use yarn, because there is no app yet, but when running ember install it does a similar check afaik, assuming it should use yarn if the project uses it.

Maybe we could copy that behavior here? Fwiw, this could be a separate PR though...

};

promise = promise
Expand All @@ -111,9 +112,14 @@ function installPristineApp(appName, options) {

// Generates the arguments to pass to `ember new`. Optionally skipping the
// npm and/or bower installation phases.
function generateArgsForEmberNew(skipNpm, skipBower) {
function generateArgsForEmberNew(skipNpm, skipBower, options) {
let extraOptions = [];

if (options.yarn) {
debug('using yarn');
extraOptions.push('--yarn');
}

if (skipNpm) {
debug('skipping npm');
extraOptions.push('--skip-npm');
Expand Down Expand Up @@ -142,11 +148,19 @@ function nodeModulesSetup(options) {
promise = promise
.then(() => {
debug('installing ember-disable-prototype-extensions');
return runCommand('npm', 'install', 'ember-disable-prototype-extensions');
if (options.yarn) {
return runCommand('yarn', 'add', 'ember-disable-prototype-extensions');
} else {
return runCommand('npm', 'install', 'ember-disable-prototype-extensions');
}
})
.then(() => {
debug("installed ember-disable-prototype-extension");
return runCommand('npm', 'install');
if (options.yarn) {
return runCommand('yarn');
} else {
return runCommand('npm', 'install');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my comment https://github.com/tomdale/ember-cli-addon-tests/pull/105/files#r118477645 and I think also what @kellyselden was suggesting, if this addon knows which package manager to use, maybe we can abstract this and the yarn add thing above away into a reusable method and make it public (like app.install() and app.install('my-addon') ) which users of this addon can use to customize their test setup without having to care about which package manager shall be used (e.g. here https://github.com/kaliber5/ember-fastboot-addon-tests/blob/master/lib/util/app-manager.js#L41)?

Can be a separate PR as well, just wanted to mention my thoughts here...

})
.then(() => debug('installed ember-data ' + emberDataVersion))
.then(() => symlinkAddon(appName))
Expand Down
5 changes: 3 additions & 2 deletions test/acceptance/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ describe('Acceptance | application', function() {
promoteHtmlbars();

return app.create('dummy', {
fixturesPath: 'tests'
fixturesPath: 'tests',
yarn: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should leave this test intact and make a new one that tests yarn. Then both our npm and yarn code paths get tested.

});
}).then(function() {
process.chdir(previousCwd);
}).then(function() {
app.editPackageJSON(function(pkg) {
pkg.devDependencies['ember-cli-fastboot'] = process.env.npm_package_devDependencies_ember_cli_fastboot;
});
return app.run('npm', 'install');
return app.run('yarn', 'install');
});
});

Expand Down
Loading