Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createWatcher(options: {
path: string,
patterns: $ReadOnlyArray
}) {
debug("path:", options.path);
debug("extensions:", options.patterns);
const watcher = sane(options.path, {
watchman: canUseWatchman,
glob: options.patterns
});
let subscribers = [];
let ready = false;
let closeMe = false;
/* eslint-disable flowtype/no-mutable-array */
const files: Array = globby
.sync(options.patterns, { cwd: options.path })
.map(file => toFile(options.path, file));
debug("files", files.map(file => file.name));
watcher.on("ready", () => {
debug("watcher: ready");
ready = true;
if (closeMe) {
_watch(
hasteMap,
hasteFS,
moduleMap)
{
if (!this._options.watch) {
return Promise.resolve();
}
// In watch mode, we'll only warn about module collisions and we'll retain
// all files, even changes to node_modules.
this._options.throwOnModuleCollision = false;
this._options.retainAllFiles = true;
const Watcher = canUseWatchman && this._options.useWatchman ?
sane.WatchmanWatcher :
sane.NodeWatcher;
const extensions = this._options.extensions;
const ignorePattern = this._options.ignorePattern;
let changeQueue = Promise.resolve();
let eventsQueue = [];
// We only need to copy the entire haste map once on every "frame".
let mustCopy = true;
const createWatcher = root => {
const watcher = new Watcher(root, {
dot: false,
glob: extensions.map(extension => '**/*.' + extension),
ignored: ignorePattern });
return new Promise((resolve, reject) => {
hasteMap,
hasteFS,
moduleMap)
{
if (!this._options.watch) {
return Promise.resolve();
}
// In watch mode, we'll only warn about module collisions and we'll retain
// all files, even changes to node_modules.
this._options.throwOnModuleCollision = false;
this._options.retainAllFiles = true;
const Watcher = canUseWatchman && this._options.useWatchman ?
sane.WatchmanWatcher :
sane.NodeWatcher;
const extensions = this._options.extensions;
const ignorePattern = this._options.ignorePattern;
let changeQueue = Promise.resolve();
let eventsQueue = [];
// We only need to copy the entire haste map once on every "frame".
let mustCopy = true;
const createWatcher = root => {
const watcher = new Watcher(root, {
dot: false,
glob: extensions.map(extension => '**/*.' + extension),
ignored: ignorePattern });
return new Promise((resolve, reject) => {
const rejectTimeout = setTimeout(
github,
logo,
sheets: ['app.css'],
scripts: scripts
? scripts.map(s => `scripts/${path.basename(s)}`)
: [],
colors,
});
return acc;
}, {});
} catch (e) {
console.log(chalk.red(`Error building files: ${e.toString()}`));
}
};
const watcher = sane(root, {
watchman: true,
glob: ['**/*.md', '**/*.mdx', '**/*.js', '**/*.ts', '**/*.tsx'],
ignored: /node_modules/,
});
watcher.on('change', callback('change'));
watcher.on('add', callback('add'));
watcher.on('delete', callback('delete'));
const cleanup = () => {
watcher.close();
process.exit();
};
const error = e => {
console.log(e.stack || e.message);
env: {
...process.env,
},
stdio: 'inherit'
});
child.on('exit', code => {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
var watcher = sane(srcDir, { glob: ['**/*.js', '**/*.graphql'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', () => {
console.log(CLEARLINE + yellow(invert('stopped watching')));
watcher.close();
process.exit();
});
var isChecking;
var needsCheck;
var toCheck = {};
var timeout;
child.on('exit', function(code) {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
var flowServer = spawn(flowBinPath, ['server'], {
cmd: cmd,
env: process.env,
});
var watcher = sane(srcDir, { glob: ['**/*.*'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', function() {
watcher.close();
flowServer.kill();
console.log(CLEARLINE + yellow(invert('stopped watching')));
process.exit();
});
var isChecking;
var needsCheck;
var toCheck = {};
var timeout;
child.on('exit', function (code) {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
var flowServer = spawn(flowBinPath, ['server'], {
cmd: cmd,
env: process.env
});
var watcher = sane(srcDir, { glob: ['**/*.*'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', function () {
watcher.close();
flowServer.kill();
console.log(CLEARLINE + yellow(invert('stopped watching')));
process.exit();
});
var isChecking;
var needsCheck;
var toCheck = {};
var timeout;
child.on('exit', code => {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
const flowServer = spawn(flowBinPath, ['server'], {
cmd,
env: process.env,
});
const watcher = sane(srcDir, { glob: ['**/*.js', '**/*.graphql'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', () => {
watcher.close();
flowServer.kill();
console.log(CLEARLINE + yellow(invert('stopped watching')));
process.exit();
});
let isChecking;
let needsCheck;
let toCheck = {};
let timeout;
child.on('exit', function (code) {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
var flowServer = spawn(flowBinPath, ['server'], {
cmd: cmd,
env: process.env
});
var watcher = sane(srcDir, { glob: ['**/*.*'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', function () {
watcher.close();
flowServer.kill();
console.log(CLEARLINE + yellow(invert('stopped watching')));
process.exit();
});
var isChecking;
var needsCheck;
var toCheck = {};
var timeout;
var server = fork('lib/bin/server.js');
server.on('stdout', (m) => {
console.log(blue(m));
})
/*
var server = spawn('node', ['--harmony', 'lib/bin/server.js'], {
cmd: cmd,
env: process.env,
stdio: 'inherit'
});
*/
var watcher = sane(cmd, { glob: ['server/**/*.*', 'client/**/*.*'] })
.on('ready', startWatch)
.on('add', changeFile)
.on('delete', deleteFile)
.on('change', changeFile);
process.on('SIGINT', function () {
console.log(CLEARLINE + yellow(invert('dev server killed')));
bs.exit();
flowServer.kill();
server.kill();
watcher.close();
process.exit();
});
process.on('uncaughtException', (err) => {
console.log(CLEARLINE + red(invert(`Caught exception: ${err}`)));