Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require ResultSummary before any npm scenarios run #122

Merged
merged 3 commits into from
Mar 28, 2017
Merged
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
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ bower.json
ember-cli-build.js
testem.js
all-commands.sh
smoke-test.sh
testem.json
upload-coverage.sh
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ node_js:

sudo: false

cache:
directories:
- node_modules

env:
- NPM_SCRIPT=node-test

Expand All @@ -23,8 +19,15 @@ matrix:
env: NPM_SCRIPT=lint
- node_js: "6"
env: NPM_SCRIPT=node-test-with-coverage
- node_js: "4"
env: NPM_SCRIPT=smoke-test
- node_js: "6"
env: NPM_SCRIPT=smoke-test

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn --version
- npm config set spin false
- npm install -g bower
- bower --version
Expand Down
9 changes: 2 additions & 7 deletions lib/dependency-manager-adapters/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ module.exports = CoreObject.extend({
return RSVP.all(cleanupTasks);
}).catch(function(e) {
console.log('Error cleaning up npm scenario:', e);
})
.then(function() {
var yarnLockPresent = fs.existsSync(path.join(adapter.cwd, adapter.yarnLock));
return adapter._install({ useYarnLock: yarnLockPresent });
});
},
_setYarnAvailability: function() {
Expand All @@ -95,15 +91,14 @@ module.exports = CoreObject.extend({
return null;
}
},
_install: function(options) {
_install: function() {
var adapter = this;
var opts = extend({ useYarnLock: false }, options);
var mgrOptions = this.managerOptions || [];

debug('Run npm install with options %s', mgrOptions);

var cmd = this.useYarnCommand ? 'yarn' : 'npm';
if (this.useYarnCommand && !opts.useYarnLock && mgrOptions.indexOf('--no-lockfile') === -1) {
if (this.useYarnCommand && mgrOptions.indexOf('--no-lockfile') === -1) {
mgrOptions = mgrOptions.concat(['--no-lockfile']);
}

Expand Down
6 changes: 2 additions & 4 deletions lib/tasks/try-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = CoreObject.extend({
// Required lazily to improve startup speed.
var ScenarioManager = require('./../utils/scenario-manager');
var DependencyManagerAdapterFactory = require('./../utils/dependency-manager-adapter-factory');
this.ResultSummary = require('./../utils/result-summary');

var task = this;
var dependencyManagerAdapters = task.dependencyManagerAdapters || DependencyManagerAdapterFactory.generateFromConfig(task.config, task.project.root);
Expand Down Expand Up @@ -120,10 +121,7 @@ module.exports = CoreObject.extend({
},

_printResults: function(results) {
// Required lazily to improve startup speed.
var ResultSummary = require('./../utils/result-summary');

new ResultSummary({ ui: this.ui, results: results }).print();
new this.ResultSummary({ ui: this.ui, results: results }).print();
},

_exitAsAppropriate: function(results) {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"start": "ember server",
"client-test": "./all-commands.sh",
"node-test": "mocha test/**/*.js",
"all-test": "npm run-script node-test && npm run-script smoke-test",
"node-test-with-coverage": "istanbul cover _mocha test/**/*.js && ./upload-coverage.sh",
"smoke-test": "./smoke-test.sh",
"lint": "eslint lib test",
"test": "npm run-script lint && npm run-script node-test && npm run-script client-test"
},
Expand Down
11 changes: 11 additions & 0 deletions smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -ex

# cleanup to avoid nested folders accumulation due to node_modules
# folder being cached in CI
rm -rf node_modules/ember-try

npm link
npm link ember-try

ember try:one test2 --config-path='test/fixtures/dummy-ember-try-config-with-npm-scenarios.js'
42 changes: 1 addition & 41 deletions test/dependency-manager-adapters/npm-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,7 @@ describe('npmAdapter', function() {
_runYarnCheck: passedYarnCheck,
managerOptions: ['--flat']
})._install().then(function() {
expect(runCount).to.equal(1, 'Only yarn install should run with manager options and --no-lockfile');
});
});

it('runs yarn install with lockfile if given option', function() {
writeJSONFile('package.json', fixturePackage);
var runCount = 0;
var stubbedRun = generateMockRun([{
command: 'yarn install',
callback: function() {
runCount++;
return RSVP.resolve();
}
}], { allowPassthrough: false });

return new NpmAdapter({
cwd: tmpdir,
run: stubbedRun,
_runYarnCheck: passedYarnCheck
})._install({ useYarnLock: true }).then(function() {
expect(runCount).to.equal(1, 'Only yarn install should run without --no-lockfile');
expect(runCount).to.equal(1, 'Only yarn install should run with manager options');
});
});
});
Expand Down Expand Up @@ -261,26 +241,6 @@ describe('npmAdapter', function() {
expect(npmAdapter.useYarnCommand).to.equal(false);
});
});

describe('#cleanup', function() {
it('runs _install using yarn lock if present', function() {
fs.writeFileSync('yarn.lock', 'stuff');
var installOptions = {};
function mockInstall(options) {
installOptions = options;
}

return new NpmAdapter({
cwd: tmpdir,
_restoreOriginalDependencies: function() {
return RSVP.resolve();
},
_install: mockInstall
}).cleanup().then(function() {
expect(installOptions).to.eql({ useYarnLock: true });
});
});
});
});

function assertFileContainsJSON(filename, expectedObj) {
Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/dummy-ember-try-config-with-npm-scenarios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
scenarios: [
{
name: 'test1',
bower: {
dependencies: {
ember: '1.10.0'
}
}
},
{
name: 'test2',
command: 'ember test',
npm: {
dependencies: {
'ember-feature-flags': '3.0.0'
}
}
}
]
};