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

allow removing npm packages #106

Merged
merged 2 commits into from
Oct 26, 2016
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This command is deprecated in favor of `ember try:one`. There are several bugs w
### Config

##### versionCompatibility
If you're using `ember-try` with an Ember addon, there is a short cut to test many Ember versions. In your `package.json` under the `ember-addon` key, add the following:
If you're using `ember-try` with an Ember addon, there is a short cut to test many Ember versions. In your `package.json` under the `ember-addon` key, add the following:

```json
"ember-addon": {
Expand All @@ -92,7 +92,7 @@ If you're using `ember-try` with an Ember addon, there is a short cut to test ma
```

The value for "ember" can be any valid [semver statement](https://github.com/npm/node-semver).
This will autogenerate scenarios for each version of Ember that matches the statement. It will also include scenarios for `beta` and `canary` channels of Ember that will be allowed to fail.
This will autogenerate scenarios for each version of Ember that matches the statement. It will also include scenarios for `beta` and `canary` channels of Ember that will be allowed to fail.
These scenarios will ONLY be used if `scenarios` is NOT a key in the configuration file being used.
If `useVersionCompatibility` is set to `true` in the config file, the autogenerated scenarios will deep merge with any scenarios in the config file. For example, you could override just the `allowedToFail` property of the `ember-beta` scenario.

Expand Down Expand Up @@ -157,7 +157,10 @@ module.exports = function() {
allowedToFail: true,
npm: {
devDependencies: {
'ember-data': '2.3.0'
'ember-data': '2.3.0',

// you can remove any package by marking `undefined`
'some-optional-package': undefined
}
},
bower: {
Expand Down Expand Up @@ -227,7 +230,7 @@ If no `config/ember-try.js` file is present, the default config will be used. Th
]
}
```
### Video
### Video
[![How to use EmberTry](https://i.vimeocdn.com/video/559399937_500.jpg)](https://vimeo.com/157688157)

See an example of using `ember-try` for CI [here](https://github.com/kategengler/ember-feature-flags/commit/aaf0226975c76630c875cf6b923fdc23b025aa79), and the resulting build [output](https://travis-ci.org/kategengler/ember-feature-flags/builds/55597086).
Expand Down
8 changes: 7 additions & 1 deletion lib/dependency-manager-adapters/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ module.exports = CoreObject.extend({
if (!packageJSON[kindOfDependency]) {
packageJSON[kindOfDependency] = {};
}
packageJSON[kindOfDependency][pkg] = depSet[kindOfDependency][pkg];

var version = depSet[kindOfDependency][pkg];
if (version === undefined) {
delete packageJSON[kindOfDependency][pkg];
} else {
packageJSON[kindOfDependency][pkg] = version;
}
});
},
_restoreOriginalDependencies: function() {
Expand Down
10 changes: 10 additions & 0 deletions test/dependency-manager-adapters/npm-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ describe('npmAdapter', function() {

expect(resultJSON.peerDependencies['ember-cli-babel']).to.equal('4.0.0');
});

it('can remove a package', function() {
var npmAdapter = new NpmAdapter({cwd: tmpdir});
var packageJSON = { devDependencies: { 'ember-feature-flags': '1.0.0' } };
var depSet = { devDependencies: { 'ember-feature-flags': undefined } };

var resultJSON = npmAdapter._packageJSONForDependencySet(packageJSON, depSet);

expect(resultJSON.devDependencies).to.not.have.property('ember-feature-flags');
});
});
});

Expand Down