From b7af43f3f9af9c1e0ebabe059e32a0892871e9f6 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Mon, 7 Oct 2024 15:19:08 -0700 Subject: [PATCH 1/6] tmp save --- src/asar.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/asar.ts b/src/asar.ts index 6b380d2..c8e86e7 100644 --- a/src/asar.ts +++ b/src/asar.ts @@ -26,7 +26,10 @@ function isUnpackedDir(dirPath: string, pattern: string, unpackDirs: string[]) { } return true; } else { - return unpackDirs.some((unpackDir) => dirPath.startsWith(unpackDir)); + return unpackDirs.some( + (unpackDir) => + dirPath.startsWith(unpackDir) && !path.relative(dirPath, unpackDir).includes('../'), + ); } } From fdad770c083d52200bf0abc0665cc1286a7e1c14 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 15 Oct 2024 12:31:48 -0700 Subject: [PATCH 2/6] update test case to test minimatch pattern --- src/asar.ts | 2 +- test/cli-spec.js | 5 +++-- .../dir2/subdir-do-not-unpack/file2.png | Bin 0 -> 182 bytes 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 test/input/packthis-subdir/dir2/subdir-do-not-unpack/file2.png diff --git a/src/asar.ts b/src/asar.ts index c8e86e7..3a9332b 100644 --- a/src/asar.ts +++ b/src/asar.ts @@ -28,7 +28,7 @@ function isUnpackedDir(dirPath: string, pattern: string, unpackDirs: string[]) { } else { return unpackDirs.some( (unpackDir) => - dirPath.startsWith(unpackDir) && !path.relative(dirPath, unpackDir).includes('../'), + dirPath.startsWith(unpackDir) && !path.relative(unpackDir, dirPath).startsWith('../') ); } } diff --git a/test/cli-spec.js b/test/cli-spec.js index b91d27a..0daf657 100644 --- a/test/cli-spec.js +++ b/test/cli-spec.js @@ -174,13 +174,14 @@ describe('command line interface', function () { 'test/expected/packthis-unpack-dir.asar', ); }); - it('should create archive from directory with unpacked subdirs and files', async () => { + it('should create archive from directory with unpacked subdirs and files using minimatch', async () => { await execAsar( - 'p test/input/packthis-subdir/ tmp/packthis-unpack-subdir-cli.asar --unpack *.txt --unpack-dir dir2/subdir --exclude-hidden', + 'p test/input/packthis-subdir/ tmp/packthis-unpack-subdir-cli.asar --unpack *.txt --unpack-dir "{dir2/subdir,dir2/subdir}" --exclude-hidden', ); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/file0.txt')); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir1/file1.txt')); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir/file2.png')); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir/file3.txt')); + assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir-do-not-unpack/file2.png') === false); }); }); diff --git a/test/input/packthis-subdir/dir2/subdir-do-not-unpack/file2.png b/test/input/packthis-subdir/dir2/subdir-do-not-unpack/file2.png new file mode 100644 index 0000000000000000000000000000000000000000..a3986deb3a782923a9617b1919c58dfacd232c3e GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1SGw4HSYi^#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7i zo^j8!=>b4B>Ygr+Arj%q2iX55GqkWwVP$(Eq%hThEn>z37MTSe3m8|hh#fe Date: Tue, 15 Oct 2024 12:40:51 -0700 Subject: [PATCH 3/6] yarn prettier --- src/asar.ts | 2 +- test/cli-spec.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/asar.ts b/src/asar.ts index 3a9332b..e39c200 100644 --- a/src/asar.ts +++ b/src/asar.ts @@ -28,7 +28,7 @@ function isUnpackedDir(dirPath: string, pattern: string, unpackDirs: string[]) { } else { return unpackDirs.some( (unpackDir) => - dirPath.startsWith(unpackDir) && !path.relative(unpackDir, dirPath).startsWith('../') + dirPath.startsWith(unpackDir) && !path.relative(unpackDir, dirPath).startsWith('../'), ); } } diff --git a/test/cli-spec.js b/test/cli-spec.js index 0daf657..ed0e0cc 100644 --- a/test/cli-spec.js +++ b/test/cli-spec.js @@ -182,6 +182,10 @@ describe('command line interface', function () { assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir1/file1.txt')); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir/file2.png')); assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir/file3.txt')); - assert.ok(fs.existsSync('tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir-do-not-unpack/file2.png') === false); + assert.ok( + fs.existsSync( + 'tmp/packthis-unpack-subdir-cli.asar.unpacked/dir2/subdir-do-not-unpack/file2.png', + ) === false, + ); }); }); From bc27f9066a1456d91a4516f07e6325278de2d55d Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 15 Oct 2024 13:37:07 -0700 Subject: [PATCH 4/6] remove path separator as it differs on windows --- src/asar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asar.ts b/src/asar.ts index e39c200..002af42 100644 --- a/src/asar.ts +++ b/src/asar.ts @@ -28,7 +28,7 @@ function isUnpackedDir(dirPath: string, pattern: string, unpackDirs: string[]) { } else { return unpackDirs.some( (unpackDir) => - dirPath.startsWith(unpackDir) && !path.relative(unpackDir, dirPath).startsWith('../'), + dirPath.startsWith(unpackDir) && !path.relative(unpackDir, dirPath).startsWith('..'), ); } } From 9ad9ceb92f6a2af02fea009916b413679157fd6b Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 15 Oct 2024 13:42:06 -0700 Subject: [PATCH 5/6] retrigger build as the timeout is unrelated to edited unit test From 6a5d67668b31c3101796e12311cdb7da3fe47736 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Mon, 21 Oct 2024 08:38:31 -0700 Subject: [PATCH 6/6] empty commit