Show specific error message when chokidar can't be loaded
This commit is contained in:
parent
f81d9e1274
commit
005c4cb7a8
@ -64,7 +64,7 @@ module.exports = function (commander, filenames) {
|
||||
_.each(filenames, handle);
|
||||
|
||||
if (commander.watch) {
|
||||
let chokidar = require("chokidar");
|
||||
let chokidar = util.requireChokidar();
|
||||
|
||||
_.each(filenames, function (dirname) {
|
||||
let watcher = chokidar.watch(dirname, {
|
||||
|
||||
@ -132,7 +132,7 @@ module.exports = function (commander, filenames, opts) {
|
||||
walk();
|
||||
|
||||
if (commander.watch) {
|
||||
let chokidar = require("chokidar");
|
||||
let chokidar = util.requireChokidar();
|
||||
chokidar.watch(filenames, {
|
||||
persistent: true,
|
||||
ignoreInitial: true
|
||||
|
||||
@ -71,3 +71,12 @@ process.on("uncaughtException", function (err) {
|
||||
console.error(toErrorStack(err));
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export function requireChokidar() {
|
||||
try {
|
||||
return require("chokidar");
|
||||
} catch (err) {
|
||||
console.error("The optional dependency chokidar failed to install and is required for --watch. Chokidar is likely not supported on your platform.")
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user