Michael Kühnel
Frontend Developer working for Micromata 👨🏼💻
npm Scripts | Gulp | Grunt | |
---|---|---|---|
Was | Aliasing von Shell Befehlen | Task Runner | Task Runner |
Übergabe von Dateien | Bash based (| bzw. >) |
Stream based | File based |
Windows Support | It depends | Ja | Ja |
CLI option abstrahiert | Nein | Ja | Ja |
Konfiguration | Bash Befehle | Code over configuration | Configuration over code |
{
"name": "npm-run-scripts",
"version": "0.0.0",
"devDependencies": {
"nsp": "^2.6.3",
"eslint": "^3.18.0",
"eslint-config-xo-space": "^0.16.0",
"jest": "^19.0.2",
"jest-cli": "^19.0.1"
},
"scripts": {
"prepublish": "nsp check",
"pretest": "eslint . --ignore-path .gitignore --fix",
"test": "jest",
"build": "npm test && npm prepublish"
}
}
$ npm run build
{
"name": "gulp-demo-setup",
"version": "0.0.0",
"devDependencies": {
"eslint": "^3.1.1",
"eslint-config-xo-space": "^0.15.0",
"gulp": "^3.9.0",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^3.0.1",
"gulp-plumber": "^1.0.0",
"gulp-nsp": "^2.1.0"
},
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp"
}
}
$ gulp build
'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
gulp.task('static', function () {
return gulp.src('**/*.js')
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('nsp', function (cb) {
nsp({package: path.resolve('package.json')}, cb);
});
gulp.task('test', function (cb) {
var mochaErr;
gulp.src('test/**/*.js')
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
mochaErr = err;
})
.pipe(istanbul.writeReports())
.on('end', function () {
cb(mochaErr);
});
});
gulp.task('watch', function () {
gulp.watch(['lib/**/*.js', 'test/**'], ['test']);
});
gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test']);
gulp.task('build', ['static', 'test', 'nsp']);
{
"name": "grunt-demo-setup",
"version": "0.0.0",
"devDependencies": {
"blanket": "^1.2.3",
"eslint": "3.18.0",
"eslint-config-xo-space": "^0.16.0",
"grunt": "1.0.1",
"grunt-eslint": "19.0.0",
"grunt-mocha-test": "^0.13.2",
"grunt-notify": "0.4.5",
"grunt-nsp": "^2.3.1",
"load-grunt-tasks": "3.5.2",
"time-grunt": "1.4.0"
},
"scripts": {
"prepublish": "grunt security",
"test": "grunt"
}
}
$ grunt build
'use strict';
var getTasks = require('load-grunt-tasks');
var displayTime = require('time-grunt');
module.exports = function (grunt) {
getTasks(grunt, {scope: 'devDependencies'});
displayTime(grunt);
grunt.initConfig({
eslint: {
options: {
ignorePattern: '!.postinstall.js',
fix: true
},
src: ['Gruntfile.js', 'lib/*.js']
},
mochaTest: {
test: {
options: {reporter: 'spec'},
src: ['test/**/*.js']
},
coverage: {
options: {
reporter: 'html-cov',
quiet: true,
captureFile: 'coverage.html'
},
src: ['test/**/*.js']
}
},
nsp: {
package: grunt.file.readJSON('package.json')
}
});
grunt.registerTask('default', ['eslint', 'mochaTest']);
grunt.registerTask('build', ['eslint', 'mochaTest', 'nsp']);
grunt.registerTask('security', ['nsp']);
};
Note: Bootstrap Kickstart wird zukünftig
(ab v4) Gulp verwenden.
By Michael Kühnel