Skip to content

Commit

Permalink
fix: add policy file to git
Browse files Browse the repository at this point in the history
Some users are forgetting to add their policy file to git, and then sending up their projects to CI systems like travis, which fail because the policy isn't in place.

This helps mitigate this problem for them. Note that we do not commit the file, I feel that this would be too far.
  • Loading branch information
remy committed Apr 15, 2016
1 parent 8a5415d commit e1f75e7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions cli/commands/protect/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var tryRequire = require('snyk-try-require');
var chalk = require('chalk');
var url = require('url');
var _ = require('lodash');
var exec = require('child_process').exec;
var undefsafe = require('undefsafe');
var auth = require('../auth');
var getVersion = require('../version');
Expand Down Expand Up @@ -211,7 +212,24 @@ function processAnswers(answers, policy, options) {
throw e;
}

return snyk.policy.save(policy, cwd, spinner);
return snyk.policy.save(policy, cwd, spinner).then(function () {
return new Promise(function (resolve) {
exec('git add .snyk', {
cwd: cwd,
}, function (error, stdout, stderr) {
if (error) {
debug('error adding .snyk to git', error);
}

if (stderr) {
debug('stderr adding .snyk to git', stderr.trim());
}

// resolve either way
resolve();
});
});
});
})
.then(function () {
// re-read the package.json - because the generatePolicy can apply
Expand Down Expand Up @@ -367,4 +385,4 @@ function processAnswers(answers, policy, options) {
});

return res;
}
}

0 comments on commit e1f75e7

Please # to comment.