flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
61
BACK_BACK/node_modules/@parcel/watcher/lib/child.js
generated
vendored
Executable file
61
BACK_BACK/node_modules/@parcel/watcher/lib/child.js
generated
vendored
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
|
||||
const _require = require('chokidar'),
|
||||
FSWatcher = _require.FSWatcher;
|
||||
|
||||
const _require2 = require('@parcel/utils'),
|
||||
errorUtils = _require2.errorUtils;
|
||||
|
||||
const optionsTransfer = require('./options');
|
||||
|
||||
let watcher;
|
||||
|
||||
function sendEvent(event, path) {
|
||||
process.send({
|
||||
event: event,
|
||||
path: path
|
||||
});
|
||||
}
|
||||
|
||||
function handleError(e) {
|
||||
sendEvent('watcherError', errorUtils.errorToJson(e));
|
||||
}
|
||||
|
||||
function init(options) {
|
||||
options = optionsTransfer.decode(options);
|
||||
watcher = new FSWatcher(options);
|
||||
watcher.on('all', sendEvent);
|
||||
sendEvent('ready');
|
||||
}
|
||||
|
||||
function executeFunction(functionName, args) {
|
||||
try {
|
||||
watcher[functionName](...args);
|
||||
} catch (e) {
|
||||
handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
process.on('message', msg => {
|
||||
switch (msg.type) {
|
||||
case 'init':
|
||||
init(msg.options);
|
||||
break;
|
||||
|
||||
case 'function':
|
||||
executeFunction(msg.name, msg.args);
|
||||
break;
|
||||
|
||||
case 'die':
|
||||
process.exit();
|
||||
break;
|
||||
|
||||
case 'emulate_error':
|
||||
throw new Error('this is an emulated error');
|
||||
}
|
||||
});
|
||||
process.on('error', handleError);
|
||||
process.on('uncaughtException', handleError);
|
||||
process.on('disconnect', () => {
|
||||
process.exit();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue