-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Build: Eval for JavaScript/TypeScript
- Loading branch information
1 parent
a81aebd
commit 86ac68f
Showing
5 changed files
with
1,689 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"shell_cmd": "node /Users/nawfalahmed/Sublime/evalNode/evalNode.js \"$file\"", | ||
"file_regex": "(...*?):([0-9]*):?([0-9]*)", | ||
"selector": "(source.jsx, source.js, source.tsx, source.ts)", | ||
"working_dir": "$file_path", | ||
"target": "terminus_exec", | ||
"cancel": "terminus_cancel_build", | ||
"focus": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import ts from 'typescript' | ||
const { transpile } = ts | ||
|
||
import fs from 'fs' | ||
const { readFileSync } = fs | ||
|
||
const keypress = async () => { | ||
process.stdin.setRawMode(true) | ||
return new Promise(resolve => process.stdin.once('data', () => { | ||
process.stdin.setRawMode(false) | ||
resolve() | ||
})) | ||
} | ||
const messages = [] | ||
function alert(message) { | ||
messages.push(message) | ||
} | ||
(async () => { | ||
const data = readFileSync(process.argv[2], 'utf8') | ||
let result = transpile(data) | ||
let last = await eval(result) | ||
for (let message of messages) { | ||
console.log(message, "[Enter]",) | ||
await keypress() | ||
} | ||
if (last != undefined) | ||
console.log(last) | ||
})().then(process.exit) |
Oops, something went wrong.