Last active
October 8, 2021 23:07
-
-
Save inad9300/1725e25a3e844c6a574074a3ee15f6f3 to your computer and use it in GitHub Desktop.
Compile and run simple TypeScript scripts.
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
#!/usr/bin/env node | |
const { execSync } = require('child_process') | |
const [inputScript] = process.argv.slice(2) | |
const outputScript = inputScript.slice(0, -3) + '.js' | |
console.log('Compiling...') | |
execSync(`./node_modules/.bin/tsc --target ESNext --module CommonJS --outDir /tmp ${inputScript}`, { stdio: 'inherit' }) | |
console.log('Running...') | |
execSync(`node /tmp/${outputScript}`, { stdio: 'inherit' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment