Created
August 28, 2017 14:23
-
-
Save stoikerty/d581017d6ae5e279a45cad97c829101e to your computer and use it in GitHub Desktop.
Modern javascript at all times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
// Teach Node how to use babel compilation, using closest babelrc config | |
require('babel-register'); | |
// Run specified file from second argument when first argument `--run` or `-r` is given | |
const options = process.argv.slice(2); | |
const runCommandGiven = (options[0] === '--run' || options[0] === '-r'); | |
const fileToRun = runCommandGiven && path.resolve(process.cwd(), options[1]); | |
if (fileToRun) { | |
require(fileToRun); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment