@@ -45,15 +45,17 @@ const buildDownloadBinaryUrl = (version) => {
4545 if ( os . arch ( ) === "arm64" ) {
4646 arch = "-arm64"
4747 }
48+ console . log ( `Downloading SimpleLocalize CLI ${ version } for ${ platform } ${ arch } ...` ) ;
4849 return `https://github.com/simplelocalize/simplelocalize-cli/releases/download/${ version } /simplelocalize-cli-${ platform } ${ arch } `
4950}
5051
51- async function installBinary ( version = "2.8.0" ) {
52- const downloadUrl = buildDownloadBinaryUrl ( version ) ;
52+ async function installBinary ( ) {
53+ const cliVersion = "2.8.0" ;
54+ const downloadUrl = buildDownloadBinaryUrl ( cliVersion ) ;
5355 if ( ! fs . existsSync ( path . join ( __dirname , 'bin' ) ) ) {
5456 fs . mkdirSync ( path . join ( __dirname , 'bin' ) ) ;
5557 }
56- console . log ( `Downloading ${ downloadUrl } ...` ) ;
58+
5759 const response = await axios ( {
5860 url : downloadUrl ,
5961 method : 'GET' ,
@@ -77,6 +79,15 @@ async function installBinary(version = "2.8.0") {
7779 console . log ( 'Binary is now executable.' ) ;
7880}
7981
82+ const linkToNodeModulesBin = ( ) => {
83+ const nodeModulesBinPath = path . join ( __dirname , '..' , '..' , '.bin' , 'simplelocalize' ) ;
84+ if ( fs . existsSync ( nodeModulesBinPath ) ) {
85+ fs . unlinkSync ( nodeModulesBinPath ) ;
86+ }
87+ fs . symlinkSync ( binaryPath , nodeModulesBinPath ) ;
88+ console . log ( 'Link to node_modules/.bin created.' ) ;
89+ }
90+
8091const init = async ( ) => {
8192 console . log ( "Checking if SimpleLocalize CLI is installed..." ) ;
8293 if ( ! isBinaryInstalled ( ) ) {
@@ -91,7 +102,8 @@ const init = async () => {
91102 console . log ( "SimpleLocalize CLI already installed." ) ;
92103 }
93104 printBinaryVersion ( ) ;
105+ linkToNodeModulesBin ( ) ;
94106 process . exit ( 0 ) ;
95107}
96108
97- await init ( ) ;
109+ init ( ) ;
0 commit comments