@@ -26,8 +26,10 @@ const pkgName = '@adamlui/minify.js',
2626 // Load sys LANGUAGE
2727 let langCode = 'en'
2828 if ( process . platform == 'win32' ) {
29- try { langCode = execSync ( '(Get-Culture).TwoLetterISOLanguageName' , { shell : 'powershell' , encoding : 'utf-8' } ) . trim ( ) }
30- catch ( err ) { printIfNotQuiet ( `Error loading system language: ${ err } ` ) }
29+ try {
30+ langCode = execSync ( '(Get-Culture).TwoLetterISOLanguageName' ,
31+ { shell : 'powershell' , encoding : 'utf-8' } ) . trim ( )
32+ } catch ( err ) { printIfNotQuiet ( `Error loading system language: ${ err } ` ) }
3133 } else { // macOS/Linux
3234 const env = process . env
3335 langCode = ( env . LANG || env . LANGUAGE || env . LC_ALL || env . LC_MESSAGES || env . LC_NAME || 'en' ) ?. split ( '.' ) [ 0 ]
@@ -48,7 +50,7 @@ const pkgName = '@adamlui/minify.js',
4850 flatMsgs [ key ] = msgs [ key ] . message
4951 resolve ( flatMsgs )
5052 } catch ( err ) { // if bad response
51- msgFetchTries ++ ; if ( msgFetchTries == 3 ) return resolve ( { } ) // try up to 3X ( original/region-stripped/EN) only
53+ msgFetchTries ++ ; if ( msgFetchTries == 3 ) return resolve ( { } ) // try original/region-stripped/EN only
5254 msgHref = langCode . includes ( '-' ) && msgFetchTries == 1 ? // if regional lang on 1st try...
5355 msgHref . replace ( / ( [ ^ _ ] * ) _ [ ^ / ] * ( \/ .* ) / , '$1$2' ) // ...strip region before retrying
5456 : ( msgHostURL + 'en/messages.json' ) // else use default English messages
@@ -147,8 +149,10 @@ const pkgName = '@adamlui/minify.js',
147149
148150 // Find all eligible JavaScript files or arg-passed file
149151 const unminnedJSfiles = inputPath . endsWith ( '.js' ) && ! fs . statSync ( inputPath ) . isDirectory ( ) ? [ inputPath ]
150- : minifyJS . findJS ( inputPath , { recursive : ! config . noRecursion , verbose : ! config . quietMode ,
151- ignoreFiles : ( config . ignoreFiles ?. split ( ',' ) ?? [ ] ) . map ( file => file . trim ( ) ) } )
152+ : minifyJS . findJS ( inputPath , {
153+ recursive : ! config . noRecursion , verbose : ! config . quietMode ,
154+ ignoreFiles : ( config . ignoreFiles ?. split ( ',' ) ?? [ ] ) . map ( file => file . trim ( ) )
155+ } )
152156
153157 if ( config . dryRun ) { // -n or --dry-run passed
154158 if ( unminnedJSfiles . length > 0 ) { // print files to be processed
@@ -172,10 +176,13 @@ const pkgName = '@adamlui/minify.js',
172176 printIfNotQuiet ( `\n${ bg + ( msgs . info_minComplete || 'Minification complete' ) } !${ nc } ` )
173177 printIfNotQuiet ( `${ bw + minifyData . length } ${ msgs . info_file || 'file' } `
174178 + `${ minifyData . length > 1 ? 's' : '' } ${ msgs . info_minified || 'minified' } .${ nc } ` )
175- } else printIfNotQuiet ( `\n${ by + ( msgs . info_noFilesProcessed || 'No unminified JavaScript files processed' ) } .${ nc } ` )
179+ } else printIfNotQuiet (
180+ `\n${ by + ( msgs . info_noFilesProcessed || 'No unminified JavaScript files processed' ) } .${ nc } ` )
176181 if ( failedPaths . length > 0 ) {
177- printIfNotQuiet ( `\n${ br + failedPaths . length } ${ msgs . info_file || 'file' } `
178- + `${ failedPaths . length > 1 ? 's' : '' } ${ msgs . info_failedToMinify || 'failed to minify' } :${ nc } ` )
182+ printIfNotQuiet (
183+ `\n${ br + failedPaths . length } ${ msgs . info_file || 'file' } `
184+ + `${ failedPaths . length > 1 ? 's' : '' } ${ msgs . info_failedToMinify || 'failed to minify' } :${ nc } `
185+ )
179186 failedPaths . forEach ( path => printIfNotQuiet ( path ) )
180187 }
181188 if ( minifyData ?. length == 0 ) return
@@ -187,13 +194,14 @@ const pkgName = '@adamlui/minify.js',
187194 ncp . writeSync ( minifyData [ 0 ] . code )
188195
189196 } else { // write array data to files
190- printIfNotQuiet ( `\n${ msgs . info_writing || 'Writing to file' } ${ minifyData ?. length > 1 ? 's' : '' } ...` )
197+ printIfNotQuiet (
198+ `\n${ msgs . info_writing || 'Writing to file' } ${ minifyData ?. length > 1 ? 's' : '' } ...` )
191199 minifyData ?. forEach ( ( { code, srcPath } ) => {
192200 const outputDir = path . join (
193201 path . dirname ( srcPath ) , // path of file to be minified
194202 ( / s o ? u ? r c e ? $ / . test ( path . dirname ( srcPath ) ) ? '../' : '' ) // + '../' if in if in *(src|source)/
195203 + ( outputArg . endsWith ( '.js' ) ? path . dirname ( outputArg ) // + path from file outputArg
196- : outputArg || 'min' ) // or path from folder outputArg or min/ if no outputArg passed
204+ : outputArg || 'min' ) // or path from folder outputArg or min/ if no outputArg passed
197205 )
198206 const outputFilename = (
199207 outputArg . endsWith ( '.js' ) && inputArg . endsWith ( '.js' )
@@ -270,7 +278,8 @@ const pkgName = '@adamlui/minify.js',
270278 }
271279 includeSections . forEach ( section => // print valid arg elems
272280 helpSections [ section ] ?. forEach ( line => printHelpMsg ( line , / h e a d e r | u s a g e / . test ( section ) ? 1 : 37 ) ) )
273- console . info ( `\n${ msgs . info_moreHelp || 'For more help' } , ${ msgs . info_visit || 'visit' } : ${ bw + docURL + nc } ` )
281+ console . info (
282+ `\n${ msgs . info_moreHelp || 'For more help' } , ${ msgs . info_visit || 'visit' } : ${ bw + docURL + nc } ` )
274283
275284 function printHelpMsg ( msg , indent ) { // wrap msg + indent 2nd+ lines
276285 const terminalWidth = process . stdout . columns || 80 ,
0 commit comments