diff --git a/lib/tasks/.eslintrc b/lib/tasks/.eslintrc index d4cadde28..709b01107 100644 --- a/lib/tasks/.eslintrc +++ b/lib/tasks/.eslintrc @@ -2,4 +2,4 @@ "rules": { "no-invalid-this": 0 } -} \ No newline at end of file +} diff --git a/lib/tasks/assets/javascripts/lint.js b/lib/tasks/assets/javascripts/lint.js index b5e17e5b4..ab6f77817 100644 --- a/lib/tasks/assets/javascripts/lint.js +++ b/lib/tasks/assets/javascripts/lint.js @@ -42,9 +42,9 @@ export default (gulp, config) => { /* Linting */ .pipe( - through.obj(function(file, enc, cb) { + through.obj(function(file, enc, done) { if (file.isNull() || file.isStream()) - return cb() + return done() /* Lint file using .eslintrc */ file.eslint = eslint.executeOnText( @@ -56,12 +56,12 @@ export default (gulp, config) => { /* Push file to next stage */ this.push(file) - cb() + done() })) /* Print errors */ .pipe( - through.obj(function(file, enc, cb) { + through.obj(function(file, enc, done) { if (file.eslint.errorCount || file.eslint.warningCount) { // eslint-disable-next-line no-console console.log(format(file.eslint.results)) @@ -69,7 +69,7 @@ export default (gulp, config) => { /* Push file to next stage */ this.push(file) - cb() + done() })) /* Terminate on error */ @@ -78,7 +78,7 @@ export default (gulp, config) => { const errors = [] /* Gather errors */ - return through.obj(function(file, enc, cb) { + return through.obj(function(file, enc, done) { const results = file.eslint /* Consider warnings as errors */ @@ -87,10 +87,10 @@ export default (gulp, config) => { /* Push file to next stage */ this.push(file) - cb() + done() /* Format errors and terminate */ - }, function(cb) { + }, function(done) { if (errors.length > 0) { const message = errors.map(file => { return file.relative @@ -100,7 +100,7 @@ export default (gulp, config) => { this.emit("error", new util.PluginError("eslint", `Terminated with errors in files: ${message}`)) } - cb() + done() }) })()) } diff --git a/lib/tasks/assets/stylesheets/lint.js b/lib/tasks/assets/stylesheets/lint.js index d61b40fe6..04ac5ae3b 100644 --- a/lib/tasks/assets/stylesheets/lint.js +++ b/lib/tasks/assets/stylesheets/lint.js @@ -35,9 +35,9 @@ export default (gulp, config) => { /* Linting */ .pipe( - through.obj(function(file, enc, cb) { + through.obj(function(file, enc, done) { if (file.isNull() || file.isStream()) - return cb() + return done() /* Lint file using .sass-lint.yml */ file.sasslint = sasslint.lintFileText({ @@ -48,17 +48,17 @@ export default (gulp, config) => { /* Push file to next stage */ this.push(file) - cb() + done() })) /* Print errors */ .pipe( - through.obj(function(file, enc, cb) { + through.obj(function(file, enc, done) { sasslint.outputResults([file.sasslint]) /* Push file to next stage */ this.push(file) - cb() + done() })) /* Terminate on error */ @@ -67,7 +67,7 @@ export default (gulp, config) => { const errors = [] /* Gather errors */ - return through.obj(function(file, enc, cb) { + return through.obj(function(file, enc, done) { const results = file.sasslint /* Consider warnings as errors during clean compilation */ @@ -76,10 +76,10 @@ export default (gulp, config) => { /* Push file to next stage */ this.push(file) - cb() + done() /* Format errors and terminate */ - }, function(cb) { + }, function(done) { if (errors.length > 0) { const message = errors.map(file => { return file.relative @@ -89,7 +89,7 @@ export default (gulp, config) => { this.emit("error", new util.PluginError("eslint", `Terminated with errors in files: ${message}`)) } - cb() + done() }) })()) } diff --git a/lib/tasks/tests/unit.js b/lib/tasks/tests/unit.js index d237ae9c3..59e8f7908 100644 --- a/lib/tasks/tests/unit.js +++ b/lib/tasks/tests/unit.js @@ -28,9 +28,9 @@ import { Server } from "karma" * ------------------------------------------------------------------------- */ export default (gulp, config) => { - return cb => { + return done => { new Server({ configFile: path.join(process.cwd(), config.tests.unit) - }, cb).start() + }, done).start() } } diff --git a/lib/tasks/tests/unit/watch.js b/lib/tasks/tests/unit/watch.js index f0d728c21..9c7ca18e8 100644 --- a/lib/tasks/tests/unit/watch.js +++ b/lib/tasks/tests/unit/watch.js @@ -21,16 +21,29 @@ */ import path from "path" -import { Server } from "karma" +import { Server, stopper } from "karma" /* ---------------------------------------------------------------------------- * Task: start karma test runner * ------------------------------------------------------------------------- */ export default () => { - return cb => { + return done => { new Server({ configFile: path.join(process.cwd(), "tests/karma.conf.js") - }, cb).start() + }, done).start() } } + +/* ---------------------------------------------------------------------------- + * Signal handler + * ------------------------------------------------------------------------- */ + +/* Register signal handler for all relevant events */ +for (const signal of ["SIGTERM", "SIGINT", "exit"]) + process.on(signal, () => { + return stopper.stop({ + port: 9876, + logLevel: "OFF" + }) + })