Skip to content

Commit

Permalink
Add --skip-ignore back to avoid .js files
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 13, 2019
1 parent 2f2be31 commit 021f2da
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ _Environment variable denoted in parentheses._
* `--files` Load files from `tsconfig.json` on startup (`TS_NODE_FILES`, default: `false`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`, default: `false`)
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`, default: `false`)
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`, default: `false`)
* `--log-error` Logs errors of types instead of exit the process (`TS_NODE_LOG_ERROR`, default: `false`)
* `--build` Emit `.tsbuildinfo` file into `.ts-node` directory (`TS_NODE_BUILD`, default: `false`)
* `--prefer-ts-exts` Re-order file extensions so that TypeScript imports are preferred (`TS_NODE_PREFER_TS_EXTS`, default: `false`)
Expand Down
4 changes: 4 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const args = arg({
'--type-check': Boolean,
'--pretty': Boolean,
'--skip-project': Boolean,
'--skip-ignore': Boolean,
'--prefer-ts-exts': Boolean,
'--log-error': Boolean,
'--build': Boolean,
Expand Down Expand Up @@ -65,6 +66,7 @@ const {
'--type-check': typeCheck = DEFAULTS.typeCheck,
'--pretty': pretty = DEFAULTS.pretty,
'--skip-project': skipProject = DEFAULTS.skipProject,
'--skip-ignore': skipIgnore = DEFAULTS.skipIgnore,
'--prefer-ts-exts': preferTsExts = DEFAULTS.preferTsExts,
'--log-error': logError = DEFAULTS.logError,
'--build': build = DEFAULTS.build
Expand Down Expand Up @@ -93,6 +95,7 @@ Options:
--files Load files from \`tsconfig.json\` on startup
--pretty Use pretty diagnostic formatter
--skip-project Skip reading \`tsconfig.json\`
--skip-ignore Skip \`--ignore\` checks
--prefer-ts-exts Prefer importing TypeScript files over JavaScript files
`)

Expand Down Expand Up @@ -128,6 +131,7 @@ const service = register({
preferTsExts,
logError,
skipProject,
skipIgnore,
compiler,
ignoreDiagnostics,
compilerOptions,
Expand Down
9 changes: 0 additions & 9 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,6 @@ describe('ts-node', function () {
return done()
})
})

it('should compile ts in node_modules', function (done) {
exec(`${BIN_EXEC} tests/node_modules/test`, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('node_modules\n')

return done()
})
})
})

describe('register', function () {
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface Options {
ignore?: string[]
project?: string
skipProject?: boolean | null
skipIgnore?: boolean | null
preferTsExts?: boolean | null
compilerOptions?: object
ignoreDiagnostics?: Array<number | string>
Expand Down Expand Up @@ -102,6 +103,7 @@ export const DEFAULTS: Options = {
ignore: split(process.env.TS_NODE_IGNORE),
project: process.env.TS_NODE_PROJECT,
skipProject: yn(process.env.TS_NODE_SKIP_PROJECT),
skipIgnore: yn(process.env.TS_NODE_SKIP_IGNORE),
preferTsExts: yn(process.env.TS_NODE_PREFER_TS_EXTS),
ignoreDiagnostics: split(process.env.TS_NODE_IGNORE_DIAGNOSTICS),
typeCheck: yn(process.env.TS_NODE_TYPE_CHECK),
Expand Down Expand Up @@ -201,7 +203,7 @@ export function register (opts: Options = {}): Register {
...(options.ignoreDiagnostics || [])
].map(Number)

const ignore = (options.ignore || []).map(str => new RegExp(str))
const ignore = options.skipIgnore ? [] : (options.ignore || ['/node_modules/']).map(str => new RegExp(str))

// Require the TypeScript compiler and configuration.
const cwd = process.cwd()
Expand Down Expand Up @@ -387,11 +389,10 @@ export function register (opts: Options = {}): Register {
// Throw an error when requiring `.d.ts` files.
if (output[0] === '') {
throw new TypeError(
'Unable to require `.d.ts` file.\n' +
`Unable to require file: ${relative(cwd, fileName)}\n` +
'This is usually the result of a faulty configuration or import. ' +
'Make sure there is a `.js`, `.json` or another executable extension and ' +
'loader (attached before `ts-node`) available alongside ' +
`\`${basename(fileName)}\`.`
'Make sure there is a `.js`, `.json` or other executable extension with ' +
'loader attached before `ts-node` available.'
)
}

Expand Down
1 change: 0 additions & 1 deletion tests/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"incremental": true,
"jsx": "react",
"noEmit": true,
// Global type definitions.
Expand Down

0 comments on commit 021f2da

Please sign in to comment.