@@ -5,11 +5,13 @@ const path = require('path');
5
5
const util = require ( 'util' ) ;
6
6
const exec = util . promisify ( require ( 'child_process' ) . exec ) ;
7
7
const axios = require ( 'axios' ) ;
8
+ const colors = require ( 'colors' ) ;
8
9
const version = require ( './utils/version_cleaner' ) ( process . argv [ process . argv . length - 1 ] ) ;
9
10
const downloadURL = `https://nodejs.org/dist/v${ version } /node-v${ version } -linux-x64.tar.xz` ;
10
11
11
12
async function main ( ) {
12
13
let runtimeFileNumber ;
14
+ console . log ( "\nStep 1: Getting Runtime File Name" ) ;
13
15
while ( true ) {
14
16
if ( ! fs . existsSync ( path . join ( `node_runtime${ runtimeFileNumber ? `_${ runtimeFileNumber } ` : "" } .js` ) ) ) {
15
17
break ;
@@ -21,26 +23,41 @@ async function main() {
21
23
}
22
24
}
23
25
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" ) ;
24
28
fs . copyFileSync ( path . join ( __dirname , 'templates' , 'node_runtime.js' ) , path . join ( nodeRunnerFile ) ) ;
25
29
fs . copyFileSync ( path . join ( __dirname , 'templates' , 'bootstrap' ) , path . join ( `bootstrap` ) ) ;
30
+ console . log ( `✔ Copied Template Files to Project Directory` . green ) ;
26
31
32
+ console . log ( "\nStep 3: Replacing Template Strings for bootstrap file" ) ;
27
33
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" ) ;
28
36
fs . writeFileSync ( path . join ( `bootstrap` ) , bootstrap ) ;
37
+ console . log ( `✔ Wrote new bootstrap file to disk` . green ) ;
29
38
39
+ console . log ( "\nStep 5: Make bootstrap file executable" ) ;
30
40
try {
31
41
await makeExecutable ( path . join ( `bootstrap` ) ) ;
42
+ console . log ( `✔ Made bootstrap file executable` . green ) ;
32
43
} catch ( e ) {
33
- console . error ( e ) ;
34
- throw e ;
44
+ console . error ( `✖ Error making bootstrap file executable` . red ) ;
45
+ return ;
35
46
}
36
47
37
48
// Download Node.js
38
49
try {
50
+ console . log ( "\nStep 6: Download Node.js" ) ;
39
51
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" ) ;
40
54
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" ) ;
41
57
fs . unlinkSync ( path . join ( `node-v${ version } -linux-x64.tar.xz` ) ) ;
58
+ console . log ( `✔ Deleted Unziped Node.js File` . green ) ;
42
59
} catch ( e ) {
43
- console . error ( e ) ;
60
+ console . error ( `✖ Error` . red ) ;
44
61
throw e ;
45
62
}
46
63
}
0 commit comments