mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added signal handler for karma
This commit is contained in:
parent
1d637134b2
commit
4dbd2978a8
@ -2,4 +2,4 @@
|
||||
"rules": {
|
||||
"no-invalid-this": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
})
|
||||
})())
|
||||
}
|
||||
|
@ -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()
|
||||
})
|
||||
})())
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user