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 64ae6d7 commit 3adbfb3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/renderer/inkProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,19 @@ 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);
var existingFile = _.find(this.files, f => f.relativePath() == path.normalize(relPath));
if( !existingFile ) {
console.log("Watch found new file - creating it: "+relPath);
this.createInkFile(newlyFoundAbsFilePath);
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 3adbfb3

Please sign in to comment.