#!/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', 'tree-kill', 'clear', 'cls', 'exit-child', 'error-recompile', // ts-node 'scope', 'emit', 'files', 'pretty', 'transpile-only', 'prefer-ts-exts', 'prefer-ts', 'exec-check', 'debug', 'log-error', 'skip-project', 'skip-ignore', 'compiler-host', 'script-mode', 'rs' ], string: [ 'dir', 'compile-timeout', 'ignore-watch', 'interval', 'debounce', 'watch', // ts-node 'compiler', 'project', 'ignore', 'ignore-diagnostics', 'compiler-options', ], alias: { 'transpile-only': 'T', 'compiler-host': 'H', ignore: 'I', 'ignore-diagnostics': 'D', 'compiler-options': 'O', compiler: 'C', project: 'P', 'script-mode': 's' }, default: { deps: false, 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)