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
@ -42,9 +42,9 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
.pipe(
|
.pipe(
|
||||||
through.obj(function(file, enc, cb) {
|
through.obj(function(file, enc, done) {
|
||||||
if (file.isNull() || file.isStream())
|
if (file.isNull() || file.isStream())
|
||||||
return cb()
|
return done()
|
||||||
|
|
||||||
/* Lint file using .eslintrc */
|
/* Lint file using .eslintrc */
|
||||||
file.eslint = eslint.executeOnText(
|
file.eslint = eslint.executeOnText(
|
||||||
@ -56,12 +56,12 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/* Print errors */
|
/* Print errors */
|
||||||
.pipe(
|
.pipe(
|
||||||
through.obj(function(file, enc, cb) {
|
through.obj(function(file, enc, done) {
|
||||||
if (file.eslint.errorCount || file.eslint.warningCount) {
|
if (file.eslint.errorCount || file.eslint.warningCount) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(format(file.eslint.results))
|
console.log(format(file.eslint.results))
|
||||||
@ -69,7 +69,7 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/* Terminate on error */
|
/* Terminate on error */
|
||||||
@ -78,7 +78,7 @@ export default (gulp, config) => {
|
|||||||
const errors = []
|
const errors = []
|
||||||
|
|
||||||
/* Gather errors */
|
/* Gather errors */
|
||||||
return through.obj(function(file, enc, cb) {
|
return through.obj(function(file, enc, done) {
|
||||||
const results = file.eslint
|
const results = file.eslint
|
||||||
|
|
||||||
/* Consider warnings as errors */
|
/* Consider warnings as errors */
|
||||||
@ -87,10 +87,10 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
|
|
||||||
/* Format errors and terminate */
|
/* Format errors and terminate */
|
||||||
}, function(cb) {
|
}, function(done) {
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
const message = errors.map(file => {
|
const message = errors.map(file => {
|
||||||
return file.relative
|
return file.relative
|
||||||
@ -100,7 +100,7 @@ export default (gulp, config) => {
|
|||||||
this.emit("error", new util.PluginError("eslint",
|
this.emit("error", new util.PluginError("eslint",
|
||||||
`Terminated with errors in files: ${message}`))
|
`Terminated with errors in files: ${message}`))
|
||||||
}
|
}
|
||||||
cb()
|
done()
|
||||||
})
|
})
|
||||||
})())
|
})())
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
.pipe(
|
.pipe(
|
||||||
through.obj(function(file, enc, cb) {
|
through.obj(function(file, enc, done) {
|
||||||
if (file.isNull() || file.isStream())
|
if (file.isNull() || file.isStream())
|
||||||
return cb()
|
return done()
|
||||||
|
|
||||||
/* Lint file using .sass-lint.yml */
|
/* Lint file using .sass-lint.yml */
|
||||||
file.sasslint = sasslint.lintFileText({
|
file.sasslint = sasslint.lintFileText({
|
||||||
@ -48,17 +48,17 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/* Print errors */
|
/* Print errors */
|
||||||
.pipe(
|
.pipe(
|
||||||
through.obj(function(file, enc, cb) {
|
through.obj(function(file, enc, done) {
|
||||||
sasslint.outputResults([file.sasslint])
|
sasslint.outputResults([file.sasslint])
|
||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/* Terminate on error */
|
/* Terminate on error */
|
||||||
@ -67,7 +67,7 @@ export default (gulp, config) => {
|
|||||||
const errors = []
|
const errors = []
|
||||||
|
|
||||||
/* Gather errors */
|
/* Gather errors */
|
||||||
return through.obj(function(file, enc, cb) {
|
return through.obj(function(file, enc, done) {
|
||||||
const results = file.sasslint
|
const results = file.sasslint
|
||||||
|
|
||||||
/* Consider warnings as errors during clean compilation */
|
/* Consider warnings as errors during clean compilation */
|
||||||
@ -76,10 +76,10 @@ export default (gulp, config) => {
|
|||||||
|
|
||||||
/* Push file to next stage */
|
/* Push file to next stage */
|
||||||
this.push(file)
|
this.push(file)
|
||||||
cb()
|
done()
|
||||||
|
|
||||||
/* Format errors and terminate */
|
/* Format errors and terminate */
|
||||||
}, function(cb) {
|
}, function(done) {
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
const message = errors.map(file => {
|
const message = errors.map(file => {
|
||||||
return file.relative
|
return file.relative
|
||||||
@ -89,7 +89,7 @@ export default (gulp, config) => {
|
|||||||
this.emit("error", new util.PluginError("eslint",
|
this.emit("error", new util.PluginError("eslint",
|
||||||
`Terminated with errors in files: ${message}`))
|
`Terminated with errors in files: ${message}`))
|
||||||
}
|
}
|
||||||
cb()
|
done()
|
||||||
})
|
})
|
||||||
})())
|
})())
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ import { Server } from "karma"
|
|||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
export default (gulp, config) => {
|
export default (gulp, config) => {
|
||||||
return cb => {
|
return done => {
|
||||||
new Server({
|
new Server({
|
||||||
configFile: path.join(process.cwd(), config.tests.unit)
|
configFile: path.join(process.cwd(), config.tests.unit)
|
||||||
}, cb).start()
|
}, done).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { Server } from "karma"
|
import { Server, stopper } from "karma"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Task: start karma test runner
|
* Task: start karma test runner
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
return cb => {
|
return done => {
|
||||||
new Server({
|
new Server({
|
||||||
configFile: path.join(process.cwd(), "tests/karma.conf.js")
|
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