File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ class Filesystem {
142
142
followLinks = typeof followLinks === 'undefined' ? true : followLinks
143
143
const info = this . getNode ( p )
144
144
145
+ if ( ! info ) {
146
+ throw new Error ( `"${ p } " was not found in this archive` )
147
+ }
148
+
145
149
// if followLinks is false we don't resolve symlinks
146
150
if ( info . link && followLinks ) {
147
151
return this . getFile ( info . link )
Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ describe('command line interface', function () {
83
83
await execAsar ( 'e test/input/extractthis-unpack.asar tmp/extractthis-unpack-cli/' )
84
84
return compDirs ( 'tmp/extractthis-unpack-cli/' , 'test/expected/extractthis' )
85
85
} )
86
+ it ( 'should throw an error when trying to extract a file that doesn\'t exist in the archive' , async ( ) => {
87
+ await assert . rejects ( execAsar ( 'ef test/input/extractthis.asar this-file-doesnt-exist.404' ) , / " ( .* ?) " w a s n o t f o u n d i n t h i s a r c h i v e / )
88
+ } )
86
89
it ( 'should create archive from directory with unpacked dirs' , async ( ) => {
87
90
await execAsar ( 'p test/input/packthis/ tmp/packthis-unpack-dir-cli.asar --unpack-dir dir2 --exclude-hidden' )
88
91
assert . ok ( fs . existsSync ( 'tmp/packthis-unpack-dir-cli.asar.unpacked/dir2/file2.png' ) )
You can’t perform that action at this time.
0 commit comments