Repository: ember-cli/ember-try (js)

Issue:
Add API for removing packages
I see that this is on your radar https://github.com/ember-cli/ember-try/pull/45#issue-128709611

> packages in package.json cannot be removed. This needs further thought and perhaps our own configuration syntax

I just came across the need for this testing ember-data back before it was an npm package. Any API thoughts?

Pull request:
allow removing npm packages
Resolves #104 

Patch:
diff --git a/README.md b/README.md
index bfddc14..2d9d363 100644
--- a/README.md
+++ b/README.md
@@ -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": {
@@ -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.
 
@@ -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: {
@@ -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).
diff --git a/lib/dependency-manager-adapters/npm.js b/lib/dependency-manager-adapters/npm.js
index 3579d7b..3400a1e 100644
--- a/lib/dependency-manager-adapters/npm.js
+++ b/lib/dependency-manager-adapters/npm.js
@@ -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() {


Test patch:
diff --git a/test/dependency-manager-adapters/npm-adapter-test.js b/test/dependency-manager-adapters/npm-adapter-test.js
index 67d8ec2..e22c45c 100644
--- a/test/dependency-manager-adapters/npm-adapter-test.js
+++ b/test/dependency-manager-adapters/npm-adapter-test.js
@@ -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');
+    });
   });
 });