Skip to content

Commit

Permalink
Merge f68e6e3 into 1541dfe
Browse files Browse the repository at this point in the history
  • Loading branch information
stelcheck committed Dec 15, 2017
2 parents 1541dfe + f68e6e3 commit 67b4481
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ ts-node -p '"Hello, world!"'

# Pipe scripts to execute with TypeScript.
echo "console.log('Hello, world!')" | ts-node

# Passing NODE_OPTIONS to the underlying process using TS_NODE_OPTIONS.
# All `TS_NODE_*` environment variables will be passed as `NODE_*` environment
# variables to your code.
TS_NODE_ENV="--inspect-brk" ts-node
```

![TypeScript REPL](https://github.com/TypeStrong/ts-node/raw/master/screenshot.png)
Expand Down
12 changes: 12 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ v8flags(function (err, v8flags) {
'--expose-http2'
])

const env: { [key: string]: string | undefined } = {}

for (const key of Object.keys(process.env)) {
const val = process.env[key]
if (key.substring(0, 8) === 'TS_NODE_') {
env[key.substring(3)] = val
} else {
env[key] = val
}
}

for (let i = 0; i < argv.length; i++) {
const arg = argv[i]
const flag = arg.split('=', 1)[0]
Expand All @@ -62,6 +73,7 @@ v8flags(function (err, v8flags) {
//
// See: https://nodejs.org/api/child_process.html#child_process_options_detached
detached: true,
env,
stdio: 'inherit'
}
)
Expand Down

0 comments on commit 67b4481

Please sign in to comment.