-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
3,874 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
const protect = module.exports = { | ||
var protect = module.exports = { | ||
ignore: require('./ignore'), | ||
update: require('./update').update, | ||
patch: require('./patch'), | ||
patchesForPackage: require('./patches-for-package'), | ||
generatePolicy, | ||
generatePolicy: generatePolicy, | ||
}; | ||
|
||
const debug = require('debug')('snyk'); | ||
const _ = require('lodash'); | ||
var debug = require('debug')('snyk'); | ||
var _ = require('lodash'); | ||
|
||
function generatePolicy(policy, tasks, live, packageManager) { | ||
const promises = ['patch', 'ignore', 'update'] | ||
.filter((task) => tasks[task].length) | ||
.map((task) => protect[task](tasks[task], live, packageManager)); | ||
var promises = ['ignore', 'update', 'patch'].filter(function (task) { | ||
return tasks[task].length; | ||
}).map(function (task) { | ||
return protect[task](tasks[task], live, packageManager); | ||
}); | ||
|
||
return Promise.all(promises) | ||
.then((res) => { | ||
// we're squashing the arrays of arrays into a flat structure | ||
// with only non-false values | ||
const results = _.flattenDeep(res).filter(Boolean); | ||
return Promise.all(promises).then(function (res) { | ||
// we're squashing the arrays of arrays into a flat structure | ||
// with only non-false values | ||
var results = _.flattenDeep(res).filter(Boolean); | ||
|
||
// then we merge the configs together using the original config | ||
// as the baseline (this lets us retain the user's existing config) | ||
results.unshift(policy); | ||
const newPolicy = _.merge.apply(_, results); | ||
// then we merge the configs together using the original config | ||
// as the baseline (this lets us retain the user's existing config) | ||
results.unshift(policy); | ||
var newPolicy = _.merge.apply(_, results); | ||
|
||
debug(JSON.stringify(newPolicy, '', 2)); | ||
debug(JSON.stringify(newPolicy, '', 2)); | ||
|
||
return newPolicy; | ||
}); | ||
return newPolicy; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.