Skip to content

Commit

Permalink
Enable the ability to set shouldIgnore array (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey authored Oct 7, 2016
1 parent 7e3d6f4 commit 9830c84
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 83 deletions.
46 changes: 28 additions & 18 deletions src/_bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { join, resolve } from 'path'
import { start } from 'repl'
import { inspect } from 'util'
import arrify = require('arrify')
import extend = require('xtend')
import Module = require('module')
import minimist = require('minimist')
import chalk = require('chalk')
Expand All @@ -22,13 +21,14 @@ interface Argv {
compiler?: string
project?: string
require?: string | string[]
ignore?: boolean | string | string[]
ignoreWarnings?: string | string[]
disableWarnings?: boolean
compilerOptions?: any
_: string[]
}

const strings = ['eval', 'print', 'compiler', 'project', 'ignoreWarnings', 'require', 'cacheDirectory']
const strings = ['eval', 'print', 'compiler', 'project', 'ignoreWarnings', 'require', 'cacheDirectory', 'ignore']
const booleans = ['help', 'fast', 'lazy', 'version', 'disableWarnings', 'cache']

const aliases: { [key: string]: string[] } = {
Expand Down Expand Up @@ -119,18 +119,19 @@ Usage: ts-node [options] [ -e script | script.ts ] [arguments]
Options:
-e, --eval [code] Evaluate code
-p, --print [code] Evaluate code and print result
-r, --require [path] Require a node module for execution
-C, --compiler [name] Specify a custom TypeScript compiler
-I, --ignoreWarnings [code] Ignore TypeScript warnings by diagnostic code
-D, --disableWarnings Ignore every TypeScript warning
-P, --project [path] Path to TypeScript project (or \`false\`)
-O, --compilerOptions [opts] JSON compiler options to merge with compilation
-L, --lazy Lazily load TypeScript compilation
-F, --fast Run TypeScript compilation in transpile mode
--no-cache Disable the TypeScript cache
--cache-directory Configure the TypeScript cache directory
-e, --eval [code] Evaluate code
-p, --print [code] Evaluate code and print result
-r, --require [path] Require a node module for execution
-C, --compiler [name] Specify a custom TypeScript compiler
-I, --ignoreWarnings [code] Ignore TypeScript warnings by diagnostic code
-D, --disableWarnings Ignore every TypeScript warning
-P, --project [path] Path to TypeScript project (or \`false\`)
-O, --compilerOptions [opts] JSON object to merge with compiler options
-L, --lazy Lazily load TypeScript compilation on demand
-F, --fast Run TypeScript compilation in transpile mode
--ignore [regexp], --no-ignore Set the ignore check (default: \`/node_modules/\`)
--no-cache Disable the TypeScript cache
--cache-directory Configure the TypeScript cache directory
`)

process.exit(0)
Expand All @@ -157,11 +158,20 @@ const isEval = isEvalScript || stop === process.argv.length
const isPrinted = argv.print != null

// Register the TypeScript compiler instance.
const service = register(extend(argv, {
const service = register({
fast: argv.fast,
lazy: argv.lazy,
cache: argv.cache,
cacheDirectory: argv.cacheDirectory,
compiler: argv.compiler,
project: argv.project,
ignore: typeof argv.ignore === 'boolean' ? argv.ignore : arrify(argv.ignore),
ignoreWarnings: arrify(argv.ignoreWarnings),
disableWarnings: argv.disableWarnings,
compilerOptions: argv.compilerOptions,
getFile: isEval ? getFileEval : getFile,
fileExists: isEval ? fileExistsEval : fileExists,
ignoreWarnings: arrify(argv.ignoreWarnings)
}))
fileExists: isEval ? fileExistsEval : fileExists
})

// TypeScript files must always end with `.ts`.
const EVAL_FILENAME = '[eval].ts'
Expand Down
Loading

0 comments on commit 9830c84

Please sign in to comment.