Skip to content

Commit

Permalink
fix issue with [] in project path on windows
Browse files Browse the repository at this point in the history
see paulmillr/chokidar#699 for more info.
ended up disabling the globbings because we're not really using them.
  • Loading branch information
paulloz committed Sep 3, 2019
1 parent a0cb0d0 commit 72cc9e2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/renderer/inkProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,17 @@ InkProject.prototype.startFileWatching = function() {
if( this.fileWatcher )
this.fileWatcher.close();

var watchPath = path.join(this.mainInk.projectDir, "**/*.ink");
this.fileWatcher = chokidar.watch(watchPath);
this.fileWatcher = chokidar.watch(this.mainInk.projectDir, {
disableGlobbing: true
});

const isInkFile = fileAbsPath => {
return fileAbsPath.split(".").pop() == "ink";
};

this.fileWatcher.on("add", newlyFoundAbsFilePath => {
if (!isInkFile(newlyFoundAbsFilePath)) { return; }

var relPath = path.relative(this.mainInk.projectDir, newlyFoundAbsFilePath);
var existingFile = _.find(this.files, f => f.relativePath() == relPath);
if( !existingFile ) {
Expand All @@ -175,6 +182,8 @@ InkProject.prototype.startFileWatching = function() {
});

this.fileWatcher.on("change", updatedAbsFilePath => {
if (!isInkFile(updatedAbsFilePath)) { return; }

var relPath = path.relative(this.mainInk.projectDir, updatedAbsFilePath);
var inkFile = _.find(this.files, f => f.relativePath() == relPath);
if( inkFile ) {
Expand All @@ -192,6 +201,8 @@ InkProject.prototype.startFileWatching = function() {
}
});
this.fileWatcher.on("unlink", removedAbsFilePath => {
if (!isInkFile(removedAbsFilePath)) { return; }

var relPath = path.relative(this.mainInk.projectDir, removedAbsFilePath);
var inkFile = _.find(this.files, f => f.relativePath() == relPath);
if( inkFile ) {
Expand Down

0 comments on commit 72cc9e2

Please sign in to comment.