Skip to content

Instantly share code, notes, and snippets.

@z7pz
Created August 9, 2021 23:09
Show Gist options
  • Save z7pz/14fc73c8e64078cd4dd0b56bb7b91783 to your computer and use it in GitHub Desktop.
Save z7pz/14fc73c8e64078cd4dd0b56bb7b91783 to your computer and use it in GitHub Desktop.
const { execSync } = require('child_process');
const version = process.versions.node.split('.')[0];
console.log(process.env.NODE_VERSION);
(async () => {
console.info('[LOG]: CHECKING NODE VERSION...')
if (version == '16') {
console.info(`[LOG]: NODE VERSION IS ${version}`)
} else {
const command = execSync(`npm init -y && npm i --save-dev node@latest && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH`).toString()
console.log('[LOG]: CLEARING IN 10 SECONDS.')
if (!command) return console.error('error in type the installing command')
setTimeout(() => {
execSync('clear');
}, 10000)
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment