Skip to content

Commit 5f86dae

Browse files
committed
test: integ tests for fs.watch with gitIgnore exclusions support
1 parent 265410c commit 5f86dae

File tree

10 files changed

+54
-33
lines changed

10 files changed

+54
-33
lines changed

dist/phoenix-fs.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ function _unlink(ws, metadata) {
309309
const watchersMap = {};
310310
function _watch(ws, metadata) {
311311
const fullPathToWatch = metadata.data.path,
312-
// array of anymatch compatible path definition. Eg. ["**/{node_modules,bower_components}/**"]. full path is checked
313-
ignoredPaths = metadata.data.ignoredPaths,
314312
// contents of a gitIgnore file as text. The given path is used as the base path for gitIgnore
315313
gitIgnorePaths = metadata.data.gitIgnorePaths,
316314
persistent = metadata.data.persistent || true,
@@ -335,10 +333,6 @@ function _watch(ws, metadata) {
335333
return true;
336334
}
337335
const relativePath = path.relative(fullPathToWatch, pathToFilter);
338-
if(anymatch(ignoredPaths, pathToFilter)){
339-
debugMode && console.log("PhoenixFS: anymatch ignored watch path: ", pathToFilter, "rel: ", relativePath);
340-
return true;
341-
}
342336
if(relativePath && gitignore.ignores(relativePath)){
343337
debugMode && console.log("PhoenixFS: gitignore ignored watch gitIgnore path: ", pathToFilter, "rel: ",relativePath);
344338
return true;
@@ -351,6 +345,7 @@ function _watch(ws, metadata) {
351345
const watcher = chokidar.watch(fullPathToWatch, {
352346
persistent,
353347
ignoreInitial,
348+
depth: 99,
354349
ignorePermissionErrors: true,
355350
ignored: path => isIgnored(path)
356351
});

dist/virtualfs.js

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/node-src/phoenix-fs.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ function _unlink(ws, metadata) {
309309
const watchersMap = {};
310310
function _watch(ws, metadata) {
311311
const fullPathToWatch = metadata.data.path,
312-
// array of anymatch compatible path definition. Eg. ["**/{node_modules,bower_components}/**"]. full path is checked
313-
ignoredPaths = metadata.data.ignoredPaths,
314312
// contents of a gitIgnore file as text. The given path is used as the base path for gitIgnore
315313
gitIgnorePaths = metadata.data.gitIgnorePaths,
316314
persistent = metadata.data.persistent || true,
@@ -335,10 +333,6 @@ function _watch(ws, metadata) {
335333
return true;
336334
}
337335
const relativePath = path.relative(fullPathToWatch, pathToFilter);
338-
if(anymatch(ignoredPaths, pathToFilter)){
339-
debugMode && console.log("PhoenixFS: anymatch ignored watch path: ", pathToFilter, "rel: ", relativePath);
340-
return true;
341-
}
342336
if(relativePath && gitignore.ignores(relativePath)){
343337
debugMode && console.log("PhoenixFS: gitignore ignored watch gitIgnore path: ", pathToFilter, "rel: ",relativePath);
344338
return true;
@@ -351,6 +345,7 @@ function _watch(ws, metadata) {
351345
const watcher = chokidar.watch(fullPathToWatch, {
352346
persistent,
353347
ignoreInitial,
348+
depth: 99,
354349
ignorePermissionErrors: true,
355350
ignored: path => isIgnored(path)
356351
});

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{
2424
"name": "node",
2525
"cmd": "node",
26-
"args": [{ "validator": "\\S+" }]
26+
"args": ["--inspect", { "validator": "\\S+" }]
2727
}
2828
]
2929
},

src/fslib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ const fileSystemLib = {
279279
}
280280
throw new Errors.ENOSYS('Phoenix fs showSaveDialog function not yet supported.');
281281
},
282-
watchAsync: function (path, ignoredPaths=[], gitIgnorePaths="") {
282+
watchAsync: function (path, gitIgnorePaths="") {
283283
if(TauriFS.isTauriPath(path)) {
284284
throw new Errors.EPERM('Cannot watch root directory!', path);
285285
} else if(TauriFS.isTauriSubPath(path)) {
286-
return NodeTauriFS.watchAsync(path, ignoredPaths, gitIgnorePaths);
286+
return NodeTauriFS.watchAsync(path, gitIgnorePaths);
287287
}
288-
return FsWatch.watchAsync(path, ignoredPaths, gitIgnorePaths);
288+
return FsWatch.watchAsync(path, gitIgnorePaths);
289289
},
290290
unwatchAsync: function (eventEmitter) {
291291
if(eventEmitter.eventEmitterID) {

src/fslib_node_ws.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,13 @@ function unlink(path, callback) {
493493
/**
494494
*
495495
* @param {string} path
496-
* @param {Array<string>} ignoredPaths - array of anymatch compatible path definition. Eg. ["/home/user/{node_modules,bower_components}/**"]. full path is checked
497496
* @param {string} gitIgnorePaths The contents of the gitIgnore file as text. The watcher will ignore all files matching git ignore.
498497
* @returns {Promise<EventEmitter>} That will be resolved with a watcher once the watcher is ready.
499498
*/
500-
async function watchAsync(path, ignoredPaths=[], gitIgnorePaths="") {
499+
async function watchAsync(path, gitIgnorePaths="") {
501500
return new Promise((resolve, reject)=>{
502501
const platformPath = Utils.getTauriPlatformPath(path);
503-
_execCommand(WS_COMMAND.WATCH, {path: platformPath, ignoredPaths, gitIgnorePaths})
502+
_execCommand(WS_COMMAND.WATCH, {path: platformPath, gitIgnorePaths})
504503
.then(({metadata})=>{
505504
const eventEmitter = getNodeEventListener(metadata.data.eventEmitterID);
506505
eventEmitter.watchPath = path;

src/fslib_watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function unwatchAll(callback) {
128128
callback();
129129
}
130130

131-
function watchAsync(path/*, _ignoredPaths=[], _gitIgnorePaths=""*/) {
131+
function watchAsync(path/* _gitIgnorePaths=""*/) {
132132
throw new Errors.EPERM('Watch async not yet supported at path!', path);
133133
}
134134

test/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
let commandId = 0, pendingCommands = {};
3333
if(window.__TAURI__){
3434
window.__TAURI__.path.resolveResource("node-src/index.js").then(async nodeSrcPath=>{
35-
command = new window.__TAURI__.shell.Command('node', nodeSrcPath);
35+
command = new window.__TAURI__.shell.Command('node', ['--inspect', nodeSrcPath]);
3636
command.on('close', data => {
3737
window.isNodeTerminated = true;
3838
console.log(`Node: command finished with code ${data.code} and signal ${data.signal}`)
@@ -86,12 +86,12 @@
8686

8787
<script src="testInit.js"></script>
8888
<script src="test-node.browser.js"></script>
89-
<script src="test-watcher.browser.js"></script>
9089
<script src="test-dir.browser.js"></script>
9190
<script src="test-file.browser.js"></script>
9291
<script src="test-copy.browser.js"></script>
9392
<script src="test.worker.js"></script>
9493
<script src="test-getPlatformPath-api.browser.js"></script>
94+
<script src="test-watcher.browser.js"></script>
9595
<script class="mocha-exec">
9696
window.virtualTestPath = '/test-phoenix-fs';
9797

0 commit comments

Comments
 (0)