Skip to content

Commit b7b1b64

Browse files
authored
Merge pull request #51 from devloco/3.4.1
Issue #50
2 parents d06570c + 37f8c50 commit b7b1b64

File tree

2 files changed

+36
-41
lines changed

2 files changed

+36
-41
lines changed

packages/create-react-wptheme-utils/fileWatcherPlugin.js

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2018-present, https://github.com/devloco
2+
* Copyright (c) 2020-present, https://github.com/devloco
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -45,7 +45,7 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
4545
const touchFile = options.touchFile;
4646
const forceBuild = function (touchFileName) {
4747
// -c to not create a file if one doesn't already exist.
48-
// Remember this file needs to be watched by WebPack, thus it should already exist
48+
// Remember this file needs to be watched by WebPack, thus it should already exist.
4949
touch("-c", touchFileName);
5050
};
5151

@@ -57,89 +57,84 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
5757
followSymlinks: options.followSymlinks || true,
5858
cwd: options.cwd || ".",
5959
disableGlobbing: options.disableGlobbing || false,
60-
usePolling: options.usePolling || true,
60+
usePolling: options.usePolling || false,
6161
interval: options.interval || 100,
6262
binaryInterval: options.binaryInterval || 300,
6363
alwaysStat: options.alwaysStat || false,
6464
depth: options.depth || 99,
6565
awaitWriteFinish: {
6666
stabilityThreshold: options.stabilityThreshold || 250,
67-
pollInterval: options.pollInterval || 100
67+
pollInterval: options.pollInterval || 100,
6868
},
6969

7070
ignorePermissionErrors: options.ignorePermissionErrors || false,
71-
atomic: options.atomic || true
71+
atomic: options.atomic || true,
7272
});
7373

7474
watcher
7575
.on(
7676
"add",
7777
options.onAddCallback ||
78-
function (path) {
79-
//forceBuild(touchFile); // causes infinite loops for "add"
80-
return null;
81-
}
78+
function (path) {
79+
//forceBuild(touchFile); // causes infinite loops for "add"
80+
return null;
81+
}
8282
)
8383
.on(
8484
"change",
8585
options.onChangeCallback ||
86-
function (path) {
87-
// console.log(`\n\n Compilation Started after change of - ${path} \n\n`);
88-
// compiler.run(function(err) {
89-
// if (err) throw err;
90-
// watcher.close();
91-
// });
92-
//console.log(`\n\n Compilation ended for change of - ${path} \n\n`);
93-
forceBuild(touchFile);
94-
}
86+
function (path) {
87+
console.log(`\n\n FileWatcherPlugin CHANGE for: ${path} \n\n`);
88+
forceBuild(touchFile);
89+
}
9590
)
9691
.on(
9792
"unlink",
9893
options.onUnlinkCallback ||
99-
function (path) {
100-
// console.log(`File ${path} has been removed`);
101-
forceBuild(touchFile);
102-
}
94+
function (path) {
95+
// console.log(`\n\n FileWatcherPlugin UNLINK for: ${path} \n\n`);
96+
forceBuild(touchFile);
97+
}
10398
);
10499

105100
watcher
106101
.on(
107102
"addDir",
108103
options.onAddDirCallback ||
109-
function (path) {
110-
// console.log(`Directory ${path} has been added`);
111-
forceBuild(touchFile);
112-
}
104+
function (path) {
105+
// console.log(`\n\n FileWatcherPlugin ADDDIR for: ${path} \n\n`);
106+
forceBuild(touchFile);
107+
}
113108
)
114109
.on(
115110
"unlinkDir",
116111
options.unlinkDirCallback ||
117-
function (path) {
118-
// console.log(`Directory ${path} has been removed`);
119-
forceBuild(touchFile);
120-
}
112+
function (path) {
113+
// console.log(`\n\n FileWatcherPlugin UNLINKDIR for: ${path} \n\n`);
114+
forceBuild(touchFile);
115+
}
121116
)
122117
.on(
123118
"error",
124119
options.onErrorCallback ||
125-
function (error) {
126-
console.log(`FileWatcherPlugin error: ${error}`);
127-
return null;
128-
}
120+
function (error) {
121+
// console.log(`FileWatcherPlugin error: ${error}`);
122+
return null;
123+
}
129124
)
130125
.on(
131126
"ready",
132127
options.onReadyCallback ||
133-
function () {
134-
console.log("Watching for changes in the Public folder.");
135-
}
128+
function () {
129+
console.log("Watching for changes in the Public folder." /*, watcher.getWatched()*/);
130+
}
136131
)
137132
.on(
138133
"raw",
139134
options.onRawCallback ||
140-
function (event, path, details) {
141-
return null;
142-
}
135+
function (event, path, details) {
136+
return null;
137+
}
143138
);
144139
});
145140
};

packages/create-react-wptheme-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devloco/create-react-wptheme-utils",
3-
"version": "3.4.1-wp.1",
3+
"version": "3.4.1-wp.2",
44
"description": "Utilities used by create-react-wptheme.",
55
"engines": {
66
"node": ">=8"

0 commit comments

Comments
 (0)