diff --git a/packages/cli-utils/task-callback.js b/packages/cli-utils/task-callback.js index dab37513d..35a6a95a5 100644 --- a/packages/cli-utils/task-callback.js +++ b/packages/cli-utils/task-callback.js @@ -4,7 +4,7 @@ module.exports = (e, cb) => { if (e) { logError(e); process.exit(1); - } else { + } else if (typeof cb === 'function') { cb(); } }; diff --git a/packages/export-cli/src/gulp/lint.js b/packages/export-cli/src/gulp/lint.js index fe2337e29..130b0a3b2 100644 --- a/packages/export-cli/src/gulp/lint.js +++ b/packages/export-cli/src/gulp/lint.js @@ -4,15 +4,11 @@ const pump = require('pump'); const { src } = require('gulp'); const completeTask = require('@parameter1/base-cms-cli-utils/task-callback'); -module.exports = (cwd, options) => (cb) => { +module.exports = (cwd, options, ignore = ['**/node_modules/**/*']) => (cb) => { pump([ - src(['**/*.js'], { cwd }), + src(['**/*.js'], { cwd, ignore }), cache('basecms-exports-lint-js'), eslint(options), - eslint.results((results, lintCb) => { - lintCb(); - cb(); - }), eslint.format(), ], e => completeTask(e, cb)); }; diff --git a/packages/export-cli/src/gulp/serve.js b/packages/export-cli/src/gulp/serve.js index 93c17518e..7f69f01f6 100644 --- a/packages/export-cli/src/gulp/serve.js +++ b/packages/export-cli/src/gulp/serve.js @@ -9,6 +9,7 @@ const lint = require('./lint'); const server = require('./server'); module.exports = (cwd, serverFile) => () => { + if (process.env.GULP_POLLING_ENABLED) log('Falling back to polling to watch files!'); const watcher = watch( ['**/*.js'], { @@ -16,6 +17,13 @@ module.exports = (cwd, serverFile) => () => { queue: false, ignoreInitial: false, ignored: ['node_modules'], + ...(process.env.GULP_POLLING_ENABLED && { + // Use polling on windows https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038/16 + interval: process.env.GULP_POLLING_INTERVAL + ? parseInt(process.env.GULP_POLLING_INTERVAL, 10) : 1000, + usePolling: true, + useFsEvents: false, + }), }, parallel(lint(cwd), server(serverFile)), ); diff --git a/packages/newsletter-cli/src/gulp/lint.js b/packages/newsletter-cli/src/gulp/lint.js index bc8a256c4..b3bee6cc7 100644 --- a/packages/newsletter-cli/src/gulp/lint.js +++ b/packages/newsletter-cli/src/gulp/lint.js @@ -4,15 +4,11 @@ const pump = require('pump'); const { src } = require('gulp'); const completeTask = require('@parameter1/base-cms-cli-utils/task-callback'); -module.exports = (cwd, options) => (cb) => { +module.exports = (cwd, options, ignore = ['**/node_modules/**/*']) => (cb) => { pump([ - src(['**/*.js', '!**/*.marko.js'], { cwd }), + src(['**/*.js', '!**/*.marko.js'], { cwd, ignore }), cache('basecms-newsletters-lint-js'), eslint(options), - eslint.results((results, lintCb) => { - lintCb(); - cb(); - }), eslint.format(), ], e => completeTask(e, cb)); }; diff --git a/packages/newsletter-cli/src/gulp/serve.js b/packages/newsletter-cli/src/gulp/serve.js index 961a551fd..920ff47c5 100644 --- a/packages/newsletter-cli/src/gulp/serve.js +++ b/packages/newsletter-cli/src/gulp/serve.js @@ -18,6 +18,7 @@ const { LIVERELOAD_PORT } = process.env; module.exports = (cwd, serverFile) => () => { livereload.listen({ port: LIVERELOAD_PORT, quiet: true }); log(`Livereload ${green('listening')} on port ${magenta(LIVERELOAD_PORT)}`); + if (process.env.GULP_POLLING_ENABLED) log('Falling back to polling to watch files!'); const watcher = watch( [ '**/*.js', @@ -30,6 +31,13 @@ module.exports = (cwd, serverFile) => () => { queue: false, ignoreInitial: false, ignored: ['**/*.marko.js', 'node_modules'], + ...(process.env.GULP_POLLING_ENABLED && { + // Use polling on windows https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038/16 + interval: process.env.GULP_POLLING_INTERVAL + ? parseInt(process.env.GULP_POLLING_INTERVAL, 10) : 1000, + usePolling: true, + useFsEvents: false, + }), }, parallel(lint(cwd), server(serverFile)), ); diff --git a/packages/web-cli/src/gulp/lint-js.js b/packages/web-cli/src/gulp/lint-js.js index fbb8c8a58..07a887c6a 100644 --- a/packages/web-cli/src/gulp/lint-js.js +++ b/packages/web-cli/src/gulp/lint-js.js @@ -4,15 +4,11 @@ const pump = require('pump'); const { src } = require('gulp'); const completeTask = require('@parameter1/base-cms-cli-utils/task-callback'); -module.exports = (cwd, options) => (cb) => { +module.exports = (cwd, options, ignore = ['**/node_modules/**/*']) => (cb) => { pump([ - src(['server/**/*.js', '!server/**/*.marko.js'], { cwd }), + src(['server/**/*.js', '!server/**/*.marko.js'], { cwd, ignore }), cache('basecms-lint-js'), eslint(options), - eslint.results((results, lintCb) => { - lintCb(); - cb(); - }), eslint.format(), eslint.failAfterError(), ], e => completeTask(e, cb)); diff --git a/packages/web-cli/src/gulp/lint-sass.js b/packages/web-cli/src/gulp/lint-sass.js index dd79fca27..1890575c3 100644 --- a/packages/web-cli/src/gulp/lint-sass.js +++ b/packages/web-cli/src/gulp/lint-sass.js @@ -4,9 +4,9 @@ const styelint = require('gulp-stylelint'); const { src } = require('gulp'); const completeTask = require('@parameter1/base-cms-cli-utils/task-callback'); -module.exports = (cwd, options) => (cb) => { +module.exports = (cwd, options, ignore = ['**/node_modules/**/*']) => (cb) => { pump([ - src('server/styles/**/*.scss', { cwd }), + src('server/styles/**/*.scss', { cwd, ignore }), cache('basecms-lint-sass'), styelint({ ...options, diff --git a/packages/web-cli/src/gulp/serve.js b/packages/web-cli/src/gulp/serve.js index 74127cedd..2c7ef2985 100644 --- a/packages/web-cli/src/gulp/serve.js +++ b/packages/web-cli/src/gulp/serve.js @@ -19,6 +19,7 @@ const { LIVERELOAD_PORT } = process.env; module.exports = (cwd, serverFile) => () => { livereload.listen({ port: LIVERELOAD_PORT, quiet: true }); log(`Livereload ${green('listening')} on port ${magenta(LIVERELOAD_PORT)}`); + if (process.env.GULP_POLLING_ENABLED) log('Falling back to polling to watch files!'); const watcher = watch( [ serverFile, @@ -36,6 +37,13 @@ module.exports = (cwd, serverFile) => () => { queue: false, ignoreInitial: false, ignored: 'server/**/*.marko.js', + ...(process.env.GULP_POLLING_ENABLED && { + // Use polling on windows https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038/16 + interval: process.env.GULP_POLLING_INTERVAL + ? parseInt(process.env.GULP_POLLING_INTERVAL, 10) : 1000, + usePolling: true, + useFsEvents: false, + }), }, parallel(lint(cwd), series(build(cwd), server(serverFile))), );