chore: add update script for assuring clean installations (#673)

This commit is contained in:
Danny Avila 2023-07-21 13:44:59 -07:00 committed by GitHub
parent 8aa58ea240
commit deb1472aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 6 deletions

View file

@ -3,6 +3,7 @@
* This allows us to give the console some colour when running in a terminal
*/
const readline = require('readline');
const { execSync } = require('child_process');
const askQuestion = (query) => {
const rl = readline.createInterface({
@ -18,6 +19,20 @@ const askQuestion = (query) => {
);
};
function isDockerRunning() {
try {
execSync('docker info');
return true;
} catch (e) {
return false;
}
}
const silentExit = (code = 0) => {
console.log = () => {};
process.exit(code);
};
// Set the console colours
console.orange = (msg) => console.log('\x1b[33m%s\x1b[0m', msg);
console.green = (msg) => console.log('\x1b[32m%s\x1b[0m', msg);
@ -31,4 +46,6 @@ console.gray = (msg) => console.log('\x1b[90m%s\x1b[0m', msg);
module.exports = {
askQuestion,
silentExit,
isDockerRunning,
};