Created
August 7, 2018 15:49
-
-
Save halferty/9d0ea72c2a10c3c8eb34d1a3ba3851ed to your computer and use it in GitHub Desktop.
Compile and Run TypeScript from JS
This file contains hidden or 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
#!/bin/bash | |
npm install ts-node | |
npm install typescript | |
node test.js |
This file contains hidden or 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
require('ts-node').register({}); | |
process.openStdin().addListener("data", function(d) { | |
const asdf = require("./" + d.toString().trim()); | |
asdf.hello(); | |
}); |
This file contains hidden or 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
export const hello = () => console.log("hello!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment