This repository was archived by the owner on Nov 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-16
lines changed
packages/google-closure-compiler/lib Expand file tree Collapse file tree 1 file changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -17,26 +17,34 @@ import fs from 'node:fs';
1717import { createRequire } from 'node:module' ;
1818const require = createRequire ( import . meta. url ) ;
1919
20+ /** @type {!Map<string, string> } */
21+ const platformLookup = new Map ( [
22+ [ 'darwin' , 'macos' ] ,
23+ [ 'win32' , 'windows' ] ,
24+ [ 'linux' , 'linux' ] ,
25+ ] ) ;
26+
27+ /** @return {string|undefined } */
2028export const getNativeImagePath = ( ) => {
21- let compilerPath ;
22- switch ( process . platform ) {
23- case 'darwin' :
24- compilerPath = 'google-closure-compiler-macos/compiler' ;
25- break ;
26- case 'win32' :
27- compilerPath = 'google-closure-compiler-windows/compiler.exe' ;
28- break ;
29- case 'linux' :
30- compilerPath = `google-closure-compiler-linux${ process . arch === 'arm64' ? '-arm64' : '' } /compiler` ;
31- break ;
32- }
33- if ( compilerPath ) {
34- try {
35- return require . resolve ( compilerPath ) ;
36- } catch { }
29+ let platform = platformLookup . get ( process . platform ) ;
30+ let binarySuffix = '' ;
31+ if ( ! platform ) {
32+ return ;
33+ } else if ( platform === 'linux' && process . arch === 'arm64' ) {
34+ platform += '-arm64' ;
35+ } else if ( platform === 'windows' ) {
36+ binarySuffix = '.exe' ;
3737 }
38+ const compilerPath = `google-closure-compiler-${ platform } /compiler${ binarySuffix } ` ;
39+ try {
40+ return require . resolve ( compilerPath ) ;
41+ } catch { }
3842} ;
3943
44+ /**
45+ * @param {!Array<string> } platforms
46+ * @return {string }
47+ */
4048export const getFirstSupportedPlatform = ( platforms ) => {
4149 const platform = platforms . find ( ( platform , index ) => {
4250 switch ( platform . toLowerCase ( ) ) {
You can’t perform that action at this time.
0 commit comments