Skip to content

Commit

Permalink
fix(cli): fixed watch loop
Browse files Browse the repository at this point in the history
  • Loading branch information
huixisheng authored and Gcaufy committed Nov 7, 2018
1 parent 0b385e8 commit cc498ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/cli/core/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Compile extends Hook {
if (!path.isAbsolute(opt.entry)) {
this.options.entry = path.resolve(path.join(opt.src, opt.entry));
}

this.clear();
this.resolvers = {};

Expand Down Expand Up @@ -271,20 +271,22 @@ class Compile extends Hook {
return;
}
this.watchInitialized = true;
let watchOption = Object.assign({ ignoreInitial: true }, this.options.watchOption || {});
let watchOption = Object.assign({ ignoreInitial: true, depth: 99 }, this.options.watchOption || {});
let target = path.resolve(this.context, this.options.target);

if (!watchOption.ignore) {
if (watchOption.ignore) {
let type = Object.prototype.toString.call(watchOption.ignore);
if (type === '[object String]' || type === '[object RegExp]') {
watchOption.ignored = [watchOption.ignored];
watchOption.ignored.push(this.options.target);
} else if (type === '[object Array]') {
watchOption.ignored.push(this.options.target);
}
} else {
watchOption.ignored = [this.options.target];
}

chokidar.watch(['.', '!./weapp'], watchOption).on('all', (evt, filepath) => {
chokidar.watch([this.options.src], watchOption).on('all', (evt, filepath) => {
if (evt === 'change') {
let absolutePath = path.resolve(filepath);
if (this.involved[absolutePath]) {
Expand Down

0 comments on commit cc498ba

Please sign in to comment.