Skip to content

Instantly share code, notes, and snippets.

@tysg
Last active February 13, 2020 11:29
Show Gist options
  • Save tysg/bc78a7cf263f1c736fa60a02c7b4906f to your computer and use it in GitHub Desktop.
Save tysg/bc78a7cf263f1c736fa60a02c7b4906f to your computer and use it in GitHub Desktop.
import { createContext, parseError, runInContext } from '../index'
const fs = require('fs')
function main() {
const chapter = 4
const path = process.argv[2]
const code = fs.readFileSync(path, 'utf8')
const context = createContext(chapter)
runInContext(code, context).then(obj => {
if (obj.status === 'finished') {
console.log(obj.value)
} else {
console.log(parseError(context.errors))
}
})
}
main()
@tysg
Copy link
Author

tysg commented Feb 6, 2020

Create a new file src/repl/cli.ts using the code, rebuild using yarn build and run using node dist/repl/cli.js [FILE]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment