Skip to content

Instantly share code, notes, and snippets.

@austincunningham
Last active March 27, 2019 20:54
Show Gist options
  • Save austincunningham/0f6f9b009fea6d2caaa79ed15ef6765a to your computer and use it in GitHub Desktop.
Save austincunningham/0f6f9b009fea6d2caaa79ed15ef6765a to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const colors = require('colors/safe');
const readlineSync = require('readline-sync');
const execsync = require('child_process').execSync;
const fs = require('fs');
console.log('This is like Echo in the command prompt');
// npm install colors/safe --save
console.log(colors.yellow('colours work like this'))
// fs has alot of methods but this is one I found useful
// Check to see if /usr/bin/oc exists if not create it
if (!fs.existsSync('/usr/bin/oc')) {
//execSync can be used to execute any os command
execsync('sudo touch /usr/bin/oc');
}
// setting up a prompt for user interface
// npm install readline-sync --save
const result = readlineSync.question(colors.blue('Do you wish to do something else yes/no ? '));
if (result === 'yes' || result === 'y') {
// add your logic here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment