From 01c68aa9b0e8f1e56f2ced1bad7d36075b36e47f Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Thu, 2 Jan 2025 19:22:32 +0100 Subject: [PATCH 1/5] Fix test on windows cmd.exe --- test/folders.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/folders.js b/test/folders.js index d4b9aab..9ae1e3d 100644 --- a/test/folders.js +++ b/test/folders.js @@ -217,7 +217,7 @@ describe('Generating a hash over a folder, it', function () { }); }); - it('ignores a folder it is both included and excluded', async function () { + it('ignores a folder if it is both included and excluded', async function () { const hashElement = prep( Volume.fromJSON({ 'base/file1': 'content', @@ -237,8 +237,8 @@ describe('Generating a hash over a folder, it', function () { await verify({ folders: { - exclude: ['**/folder'], - include: ['**/*'], + exclude: [path.join('**','folder')], + include: [path.join('*')], matchBasename: false, matchPath: true, }, From d302b374e3b0af710c42b79f759f7f3d8f0f5e33 Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Thu, 2 Jan 2025 19:51:21 +0100 Subject: [PATCH 2/5] Fix issues in symlink tests because memfs uses posix path --- test/symbolic-links.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/symbolic-links.js b/test/symbolic-links.js index 0968819..e05a329 100644 --- a/test/symbolic-links.js +++ b/test/symbolic-links.js @@ -113,7 +113,7 @@ describe('When symbolicLinks.ignoreTargetContent is true', function () { }, }; let result = await hash('l2', options); - const expected = toHash(['l2', path.resolve('folder/file')]); + const expected = toHash(['l2', resolvePath('folder/file')]); return result.hash.should.equal(expected); }); @@ -127,7 +127,7 @@ describe('When symbolicLinks.ignoreTargetContent is true', function () { }, }; let result = await hash('l2', options); - const expected = toHash([path.resolve('folder/file')]); + const expected = toHash([resolvePath('folder/file')]); return result.hash.should.equal(expected); }); @@ -140,7 +140,7 @@ describe('When symbolicLinks.ignoreTargetContent is true', function () { }, }; let result = await hash('l1', options); - const expected = toHash(['l1', path.resolve('non-existing')]); + const expected = toHash(['l1', resolvePath('non-existing')]); return result.hash.should.equal(expected); }); }); @@ -154,7 +154,7 @@ describe('When symbolicLinks.include equals "resolve"', function () { function hashWithResolvedTargetPath(first, targetPath) { const withoutTargetPath = toHash(first); - return toHash([withoutTargetPath, path.resolve(targetPath)]); + return toHash([withoutTargetPath, resolvePath(targetPath)]); } it('can create a hash over basename file content and target path', async function () { @@ -239,7 +239,7 @@ function linkType(type) { }; return hash('soft-link', options).then(result => { - const expected = toHash(['soft-link', path.resolve('non-existing-file')]); + const expected = toHash(['soft-link', resolvePath('non-existing-file')]); result.hash.should.equal(expected); }); }); @@ -267,3 +267,11 @@ function toHash(strings) { } return hash.digest(defaultOptions().encoding); } + +function resolvePath(string) { + if (process.platform === 'win32') { + return path.posix.resolve(string) + } else { + return path.resolve.resolve(string) + } +} From eb2e71ffa9fdf0510ffd6c91bf61c2267789b80c Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Thu, 2 Jan 2025 19:54:42 +0100 Subject: [PATCH 3/5] Fix typo --- test/symbolic-links.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/symbolic-links.js b/test/symbolic-links.js index e05a329..8a16755 100644 --- a/test/symbolic-links.js +++ b/test/symbolic-links.js @@ -272,6 +272,6 @@ function resolvePath(string) { if (process.platform === 'win32') { return path.posix.resolve(string) } else { - return path.resolve.resolve(string) + return path.resolve(string) } } From ebd1e9dff18499343f0a9689dbfa79448d894e1d Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Thu, 2 Jan 2025 19:54:55 +0100 Subject: [PATCH 4/5] Remove unused import --- test/symbolic-links.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/symbolic-links.js b/test/symbolic-links.js index 8a16755..1807e4e 100644 --- a/test/symbolic-links.js +++ b/test/symbolic-links.js @@ -1,6 +1,5 @@ const { defaultOptions, prep, Volume } = require('./_common'); const crypto = require('crypto'), - clone = require('clone'), path = require('path'); describe('When hashing a symbolic link', async function () { From 30a3796e8b3d055f326b7618550f34f12a95bbe2 Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Thu, 2 Jan 2025 19:59:38 +0100 Subject: [PATCH 5/5] Fix glob expansion on win32 --- test/folders.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/folders.js b/test/folders.js index 9ae1e3d..f88a2a8 100644 --- a/test/folders.js +++ b/test/folders.js @@ -235,10 +235,12 @@ describe('Generating a hash over a folder, it', function () { result.children[1].name.should.equal('folder2'); } + const include1 = (process.platform === 'win32') ? '*' : '**/*'; + await verify({ folders: { exclude: [path.join('**','folder')], - include: [path.join('*')], + include: [include1], matchBasename: false, matchPath: true, },