Skip to content

Commit b73697e

Browse files
committed
Adding logs for each step
1 parent e0d006c commit b73697e

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const path = require('path');
55
const util = require('util');
66
const exec = util.promisify(require('child_process').exec);
77
const axios = require('axios');
8+
const colors = require('colors');
89
const version = require('./utils/version_cleaner')(process.argv[process.argv.length - 1]);
910
const downloadURL = `https://nodejs.org/dist/v${version}/node-v${version}-linux-x64.tar.xz`;
1011

1112
async 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_VERSION}}/g, version).replace(/{{NODE_VERSION}}/g, version).replace(/{{NODE_RUNNER_FILE}}/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
}

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"author": "rrainn, Inc.",
1414
"license": "MIT",
1515
"dependencies": {
16-
"axios": "^0.18.0"
16+
"axios": "^0.18.0",
17+
"colors": "^1.3.2"
1718
}
1819
}

0 commit comments

Comments
 (0)