106 lines
2.1 KiB
JavaScript
106 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
var dev = require('..')
|
|
var minimist = require('minimist')
|
|
|
|
var nodeArgs = []
|
|
|
|
var devArgs = process.argv.slice(2, 100)
|
|
var unknown = []
|
|
var opts = minimist(devArgs, {
|
|
stopEarly: true,
|
|
boolean: [
|
|
'all-deps',
|
|
'deps',
|
|
'dedupe',
|
|
'poll',
|
|
'respawn',
|
|
'notify',
|
|
'fast',
|
|
'disableWarnings',
|
|
'disable-warnings',
|
|
'no-cache',
|
|
'cache',
|
|
'type-check',
|
|
'transpile-only',
|
|
'transpileOnly',
|
|
'files',
|
|
'pretty',
|
|
'prefer-ts',
|
|
'exec-check',
|
|
'debug',
|
|
'log-error',
|
|
'prefer-ts-exts',
|
|
'tree-kill',
|
|
'clear', 'cls',
|
|
'exit-child',
|
|
'rs',
|
|
'error-recompile'
|
|
],
|
|
string: [
|
|
'compiler',
|
|
'project',
|
|
'ignore',
|
|
'skip-project',
|
|
'skip-ignore',
|
|
'ignoreWarnings',
|
|
'ignore-warnings',
|
|
'ignoreDiagnostics',
|
|
'ignore-diagnostics',
|
|
'cache-directory',
|
|
'compilerOptions',
|
|
'compiler-options',
|
|
'compile-timeout',
|
|
'ignore-watch',
|
|
'interval',
|
|
'debounce',
|
|
'watch',
|
|
'restart-terminated',
|
|
],
|
|
alias: {
|
|
transpileOnly: 'T',
|
|
fast: 'F',
|
|
ignoreDiagnostics: 'D',
|
|
ignoreWarnings: 'I',
|
|
compilerOptions: 'O',
|
|
compiler: 'C',
|
|
project: 'P',
|
|
'restart-terminated': 'rt'
|
|
},
|
|
default: { deps: true, notify: true, rs: false, 'type-check': true },
|
|
unknown: function(arg) {
|
|
unknown.push(arg)
|
|
return true
|
|
}
|
|
})
|
|
|
|
var script = opts._[0]
|
|
var scriptArgs = opts._.slice(1)
|
|
|
|
opts.priorNodeArgs = []
|
|
|
|
unknown.forEach(function(arg) {
|
|
if (arg === script || nodeArgs.indexOf(arg) >= 0) return
|
|
|
|
var argName = arg.replace(/^-+/, '')
|
|
var argOpts = opts[argName]
|
|
var argValues = Array.isArray(argOpts) ? argOpts : [argOpts]
|
|
argValues.forEach(function(argValue) {
|
|
if ((arg === '-r' || arg === '--require') && argValue === 'esm') {
|
|
opts.priorNodeArgs.push(arg, argValue)
|
|
return false
|
|
}
|
|
nodeArgs.push(arg)
|
|
if (typeof argValue === 'string') {
|
|
nodeArgs.push(argValue)
|
|
}
|
|
})
|
|
})
|
|
|
|
if (!script) {
|
|
console.log('Usage: ts-node-dev [options] script [arguments]\n')
|
|
process.exit(1)
|
|
}
|
|
|
|
dev(script, scriptArgs, nodeArgs, opts)
|