@@ -6,25 +6,35 @@ import { program } from 'commander';
66import fs from 'node:fs' ;
77import path from 'node:path' ;
88
9- const splitVersion = function ( version ) { return version . split ( '.' ) . map ( function ( part ) { return Number ( part ) } ) }
10- const requiredNodeVersion = splitVersion ( packageJSON . engines . node . slice ( 2 ) )
11- const actualNodeVersion = splitVersion ( process . versions . node )
9+ const splitVersion = function ( version ) {
10+ return version . split ( '.' ) . map ( function ( part ) {
11+ return Number ( part ) ;
12+ } ) ;
13+ } ;
14+ const requiredNodeVersion = splitVersion ( packageJSON . engines . node . slice ( 2 ) ) ;
15+ const actualNodeVersion = splitVersion ( process . versions . node ) ;
1216
13- if ( actualNodeVersion [ 0 ] < requiredNodeVersion [ 0 ] || ( actualNodeVersion [ 0 ] === requiredNodeVersion [ 0 ] && actualNodeVersion [ 1 ] < requiredNodeVersion [ 1 ] ) ) {
14- console . error ( 'CANNOT RUN WITH NODE ' + process . versions . node )
15- console . error ( 'asar requires Node ' + packageJSON . engines . node + '.' )
16- process . exit ( 1 )
17+ if (
18+ actualNodeVersion [ 0 ] < requiredNodeVersion [ 0 ] ||
19+ ( actualNodeVersion [ 0 ] === requiredNodeVersion [ 0 ] && actualNodeVersion [ 1 ] < requiredNodeVersion [ 1 ] )
20+ ) {
21+ console . error ( 'CANNOT RUN WITH NODE ' + process . versions . node ) ;
22+ console . error ( 'asar requires Node ' + packageJSON . engines . node + '.' ) ;
23+ process . exit ( 1 ) ;
1724}
1825
19- program . version ( 'v' + packageJSON . version )
20- . description ( 'Manipulate asar archive files' )
26+ program . version ( 'v' + packageJSON . version ) . description ( 'Manipulate asar archive files' ) ;
2127
22- program . command ( 'pack <dir> <output>' )
28+ program
29+ . command ( 'pack <dir> <output>' )
2330 . alias ( 'p' )
2431 . description ( 'create asar archive' )
2532 . option ( '--ordering <file path>' , 'path to a text file for ordering contents' )
2633 . option ( '--unpack <expression>' , 'do not pack files matching glob <expression>' )
27- . option ( '--unpack-dir <expression>' , 'do not pack dirs matching glob <expression> or starting with literal <expression>' )
34+ . option (
35+ '--unpack-dir <expression>' ,
36+ 'do not pack dirs matching glob <expression> or starting with literal <expression>' ,
37+ )
2838 . option ( '--exclude-hidden' , 'exclude hidden files' )
2939 . action ( function ( dir , output , options ) {
3040 options = {
@@ -34,50 +44,51 @@ program.command('pack <dir> <output>')
3444 version : options . sv ,
3545 arch : options . sa ,
3646 builddir : options . sb ,
37- dot : ! options . excludeHidden
38- }
39- createPackageWithOptions ( dir , output , options ) . catch ( error => {
40- console . error ( error )
41- process . exit ( 1 )
42- } )
43- } )
47+ dot : ! options . excludeHidden ,
48+ } ;
49+ createPackageWithOptions ( dir , output , options ) . catch ( ( error ) => {
50+ console . error ( error ) ;
51+ process . exit ( 1 ) ;
52+ } ) ;
53+ } ) ;
4454
45- program . command ( 'list <archive>' )
55+ program
56+ . command ( 'list <archive>' )
4657 . alias ( 'l' )
4758 . description ( 'list files of asar archive' )
4859 . option ( '-i, --is-pack' , 'each file in the asar is pack or unpack' )
4960 . action ( function ( archive , options ) {
5061 options = {
51- isPack : options . isPack
52- }
53- const files = listPackage ( archive , options )
62+ isPack : options . isPack ,
63+ } ;
64+ const files = listPackage ( archive , options ) ;
5465 for ( const i in files ) {
55- console . log ( files [ i ] )
66+ console . log ( files [ i ] ) ;
5667 }
57- } )
68+ } ) ;
5869
59- program . command ( 'extract-file <archive> <filename>' )
70+ program
71+ . command ( 'extract-file <archive> <filename>' )
6072 . alias ( 'ef' )
6173 . description ( 'extract one file from archive' )
6274 . action ( function ( archive , filename ) {
63- fs . writeFileSync ( path . basename ( filename ) ,
64- extractFile ( archive , filename ) )
65- } )
75+ fs . writeFileSync ( path . basename ( filename ) , extractFile ( archive , filename ) ) ;
76+ } ) ;
6677
67- program . command ( 'extract <archive> <dest>' )
78+ program
79+ . command ( 'extract <archive> <dest>' )
6880 . alias ( 'e' )
6981 . description ( 'extract archive' )
7082 . action ( function ( archive , dest ) {
71- extractAll ( archive , dest )
72- } )
83+ extractAll ( archive , dest ) ;
84+ } ) ;
7385
74- program . command ( '*' , { hidden : true } )
75- . action ( function ( _cmd , args ) {
76- console . log ( 'asar: \'%s\' is not an asar command. See \'asar --help\'.' , args [ 0 ] )
77- } )
86+ program . command ( '*' , { hidden : true } ) . action ( function ( _cmd , args ) {
87+ console . log ( "asar: '%s' is not an asar command. See 'asar --help'." , args [ 0 ] ) ;
88+ } ) ;
7889
79- program . parse ( process . argv )
90+ program . parse ( process . argv ) ;
8091
8192if ( program . args . length === 0 ) {
82- program . help ( )
93+ program . help ( ) ;
8394}
0 commit comments