Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support '#!/usr/bin/env ts-node' scripts #32

Open
rektide opened this issue Jul 9, 2020 · 0 comments
Open

Support '#!/usr/bin/env ts-node' scripts #32

rektide opened this issue Jul 9, 2020 · 0 comments

Comments

@rektide
Copy link

rektide commented Jul 9, 2020

Hello. I like being able to run my scripts locally, they usually have a little short main() function they run if they are run directly.

At the moment, if I create a short script & run tspath -f throws, tspath seems to not be able to work with it:

TSPath 1.3.7
Parsing project: take-over-the-world /iamgroot/src/take-over-the-world/
Unable to parse file: /iamgroot/src/take-over-the-world/dist/config.js
Error: Error: Line 1: Unexpected token ILLEGAL
    at ErrorHandler.constructError (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:5012:22)
    at ErrorHandler.createError (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:5028:27)
    at ErrorHandler.throwError (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:5035:21)
    at Scanner.throwUnexpectedToken (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:5164:35)
    at Scanner.scanPunctuator (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:5667:19)
    at Scanner.lex (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:6264:22)
    at Parser.nextToken (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:2079:34)
    at new Parser (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:1916:15)
    at Object.parse (/iamgroot/src/take-over-the-world/node_modules/esprima/dist/esprima.js:120:19)
    at ParserEngine.processFile (/iamgroot/src/take-over-the-world/node_modules/tspath/src/parser-engine.js:170:27) {
  index: 0,
  lineNumber: 1,
  description: 'Unexpected token ILLEGAL'
}

Example dist/config.js:

#!/usr/bin/env ts-node
console.log("hi!")

Some general description of using ts-node to make scripts directly runnable, the technique i'm trying to use, is in this great write-up: Shelling with TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant