gulp plugin for using Snyk
$ npm install --save-dev gulp-snyk
Or
$ yarn add --dev gulp-snyk
To only break the build on vulnerabilities, use snyk without any options
const snyk = require('gulp-snyk');
gulp.task('protect', function(cb) {
return snyk({ command: 'protect' }, cb);
});
gulp.task('test', function() {
return snyk({ command: 'test' }, cb);
});
gulp.task('prepublish', 'protect');
And then, in your package.json
{
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp test"
}
}
For a realistic use-case, check out the clefs plugin generator
A hash of options to configure snyk. If this is omitted, then it is the equivalent of passing the following options hash.
gulp.task('snyk-test', function(cb) {
return snyk({command: 'test', directory: process.cwd(), debug: false, options: { dev: true }}, cb);
});
Type: string
Default: test
Example:
gulp.task('protect', function(cb) {
return snyk({command: 'protect'}, cb);
});
One of the snyk command-line commands. For instance: auth, test, wizard, protect, monitor, policy.
Type: string
Default: process.cwd()
Example:
gulp.task('snyk-test', function(cb) {
return snyk({command: 'test', directory: path.join(process.cwd(), 'packages', 'my-package')}, cb);
});
The directory that contains the package on which to run the snyk command.
Type: object
Default: { dev: true }
Example:
gulp.task('snyk-wizard', function(cb) {
return snyk({command: 'wizard', options: {help: true}}, cb);
});
The options supported by the snyk command line.
Type: boolean
Default: false
Example:
gulp.task('snyk-help', function(cb) {
return snyk({command: 'test', debug: true}, cb);
});
Turns on debug logging
The callback from the asynchronous gulp task, the function passed as the first argument to the gulp task callback. For example:
gulp.task('protect', function(cb) {
return snyk({ command: 'protect' }, cb);
});
MIT © Doug Wade