@@ -5,11 +5,13 @@ const path = require('path');
55const util = require ( 'util' ) ;
66const exec = util . promisify ( require ( 'child_process' ) . exec ) ;
77const axios = require ( 'axios' ) ;
8+ const colors = require ( 'colors' ) ;
89const version = require ( './utils/version_cleaner' ) ( process . argv [ process . argv . length - 1 ] ) ;
910const downloadURL = `https://nodejs.org/dist/v${ version } /node-v${ version } -linux-x64.tar.xz` ;
1011
1112async function main ( ) {
1213 let runtimeFileNumber ;
14+ console . log ( "\nStep 1: Getting Runtime File Name" ) ;
1315 while ( true ) {
1416 if ( ! fs . existsSync ( path . join ( `node_runtime${ runtimeFileNumber ? `_${ runtimeFileNumber } ` : "" } .js` ) ) ) {
1517 break ;
@@ -21,26 +23,41 @@ async function main() {
2123 }
2224 }
2325 const nodeRunnerFile = `node_runtime${ runtimeFileNumber ? `_${ runtimeFileNumber } ` : "" } .js` ;
26+ console . log ( `✔ Got Runtime File Name: ${ nodeRunnerFile } ` . green ) ;
27+ console . log ( "\nStep 2: Copying Template Files to Project Directory" ) ;
2428 fs . copyFileSync ( path . join ( __dirname , 'templates' , 'node_runtime.js' ) , path . join ( nodeRunnerFile ) ) ;
2529 fs . copyFileSync ( path . join ( __dirname , 'templates' , 'bootstrap' ) , path . join ( `bootstrap` ) ) ;
30+ console . log ( `✔ Copied Template Files to Project Directory` . green ) ;
2631
32+ console . log ( "\nStep 3: Replacing Template Strings for bootstrap file" ) ;
2733 let bootstrap = fs . readFileSync ( path . join ( `bootstrap` ) , 'utf8' ) . replace ( / { { NODE_ V E R S I O N } } / g, version ) . replace ( / { { NODE_ V E R S I O N } } / g, version ) . replace ( / { { NODE_ R U N N E R _ F I L E } } / g, nodeRunnerFile ) ;
34+ console . log ( `✔ Replaced Template Strings for bootstrap file` . green ) ;
35+ console . log ( "\nStep 4: Write new bootstrap file to disk" ) ;
2836 fs . writeFileSync ( path . join ( `bootstrap` ) , bootstrap ) ;
37+ console . log ( `✔ Wrote new bootstrap file to disk` . green ) ;
2938
39+ console . log ( "\nStep 5: Make bootstrap file executable" ) ;
3040 try {
3141 await makeExecutable ( path . join ( `bootstrap` ) ) ;
42+ console . log ( `✔ Made bootstrap file executable` . green ) ;
3243 } catch ( e ) {
33- console . error ( e ) ;
34- throw e ;
44+ console . error ( `✖ Error making bootstrap file executable` . red ) ;
45+ return ;
3546 }
3647
3748 // Download Node.js
3849 try {
50+ console . log ( "\nStep 6: Download Node.js" ) ;
3951 await downloadFile ( downloadURL , path . join ( `node-v${ version } -linux-x64.tar.xz` ) ) ;
52+ console . log ( `✔ Downloaded Node.js` . green ) ;
53+ console . log ( "\nStep 7: Unzip Node.js" ) ;
4054 await unzip ( path . join ( `node-v${ version } -linux-x64.tar.xz` ) ) ;
55+ console . log ( `✔ Unzip Node.js` . green ) ;
56+ console . log ( "\nStep 8: Deleting Unziped Node.js File" ) ;
4157 fs . unlinkSync ( path . join ( `node-v${ version } -linux-x64.tar.xz` ) ) ;
58+ console . log ( `✔ Deleted Unziped Node.js File` . green ) ;
4259 } catch ( e ) {
43- console . error ( e ) ;
60+ console . error ( `✖ Error` . red ) ;
4461 throw e ;
4562 }
4663}
0 commit comments