Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from solocommand/windows-file-watching
Browse files Browse the repository at this point in the history
Windows file watching
  • Loading branch information
zarathustra323 authored Mar 16, 2021
2 parents 5d793dd + cb2dd4a commit 6a214ab
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/cli-utils/task-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = (e, cb) => {
if (e) {
logError(e);
process.exit(1);
} else {
} else if (typeof cb === 'function') {
cb();
}
};
8 changes: 2 additions & 6 deletions packages/export-cli/src/gulp/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
8 changes: 8 additions & 0 deletions packages/export-cli/src/gulp/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ 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'],
{
cwd,
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)),
);
Expand Down
8 changes: 2 additions & 6 deletions packages/newsletter-cli/src/gulp/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
8 changes: 8 additions & 0 deletions packages/newsletter-cli/src/gulp/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)),
);
Expand Down
8 changes: 2 additions & 6 deletions packages/web-cli/src/gulp/lint-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions packages/web-cli/src/gulp/lint-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions packages/web-cli/src/gulp/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))),
);
Expand Down

0 comments on commit 6a214ab

Please sign in to comment.