mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
add support for running custom commands in Gulp's watch task.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"husky": "^8.0.1",
|
||||
"lerna": "^6.0.1",
|
||||
"merge2": "^1.4.1",
|
||||
"minimist": "^1.2.7",
|
||||
"prettier": "^2.7.1",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"react": "^17.0.2",
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
const _ = require('lodash')
|
||||
const minimist = require('minimist')
|
||||
const { promisify } = require('util')
|
||||
const exec = promisify(require('child_process').exec)
|
||||
|
||||
const gulp = require('gulp')
|
||||
const path = require('path')
|
||||
@@ -99,9 +102,16 @@ const copyStaticFiles = () =>
|
||||
const transpileStyles = (cb) => gulp.series(transpileSass, copyCssFiles)(cb)
|
||||
|
||||
const watch = async () => {
|
||||
gulp.watch([path.join(sourceDir, '**/*.{ts,tsx,css,scss}')], (cb) => {
|
||||
build(cb)
|
||||
const { command } = minimist(process.argv.slice(2), {
|
||||
string: 'command',
|
||||
alias: ['c', 'cmd'],
|
||||
})
|
||||
|
||||
await exec(command)
|
||||
|
||||
gulp.watch([path.join(sourceDir, '**/*.{ts,tsx,css,scss}')], (cb) =>
|
||||
exec(command).finally(cb),
|
||||
)
|
||||
}
|
||||
|
||||
gulp.task('build', build)
|
||||
|
||||
Reference in New Issue
Block a user