Skip to content

Commit

Permalink
Merge pull request #106 from kellyselden/remove
Browse files Browse the repository at this point in the history
allow removing npm packages
  • Loading branch information
kategengler authored Oct 26, 2016
2 parents 15b6dd2 + d36463f commit c9c6482
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
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

0 comments on commit c9c6482

Please sign in to comment.