Skip to content

Commit

Permalink
Add backward compatibility to master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Jan 10, 2020
1 parent aa6f36f commit 8834d64
Show file tree
Hide file tree
Showing 4 changed files with 308 additions and 172 deletions.
3 changes: 3 additions & 0 deletions register/type-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('../').register({
typeCheck: true
})
8 changes: 8 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export function main (argv: string[]) {
'--ignore-diagnostics': [String],
'--ignore': [String],
'--transpile-only': Boolean,
'--type-check': Boolean,
'--compiler-host': Boolean,
'--pretty': Boolean,
'--skip-project': Boolean,
'--skip-ignore': Boolean,
Expand All @@ -69,6 +71,7 @@ export function main (argv: string[]) {
'-s': '--script-mode',
'-v': '--version',
'-T': '--transpile-only',
'-H': '--compiler-host',
'-I': '--ignore',
'-P': '--project',
'-C': '--compiler',
Expand Down Expand Up @@ -98,6 +101,8 @@ export function main (argv: string[]) {
'--ignore-diagnostics': ignoreDiagnostics,
'--ignore': ignore,
'--transpile-only': transpileOnly,
'--type-check': typeCheck,
'--compiler-host': compilerHost,
'--pretty': pretty,
'--skip-project': skipProject,
'--skip-ignore': skipIgnore,
Expand All @@ -122,6 +127,7 @@ export function main (argv: string[]) {
-s, --script-mode Use cwd from <script.ts> instead of current directory
-T, --transpile-only Use TypeScript's faster \`transpileModule\`
-H, --compiler-host Use TypeScript's compiler host API
-I, --ignore [pattern] Override the path patterns to skip compilation
-P, --project [path] Path to TypeScript JSON project file
-C, --compiler [name] Specify a custom TypeScript compiler
Expand Down Expand Up @@ -158,6 +164,8 @@ export function main (argv: string[]) {
files,
pretty,
transpileOnly,
typeCheck,
compilerHost,
ignore,
preferTsExts,
logError,
Expand Down
31 changes: 21 additions & 10 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,6 @@ describe('ts-node', function () {
})
})

it('should give ts error for invalid node_modules', function (done) {
exec(`${BIN_EXEC} --skip-ignore tests/from-node-modules`, function (err, stdout) {
if (err === null) return done('Expected an error')

expect(err.message).to.contain('Unable to compile file from external library')

return done()
})
})

if (semver.gte(ts.version, '2.7.0')) {
it('should support script mode', function (done) {
exec(`${SCRIPT_EXEC} tests/scope/a/log`, function (err, stdout) {
Expand Down Expand Up @@ -407,6 +397,27 @@ describe('ts-node', function () {
})
})
})

describe('compiler host', function () {
it('should execute cli', function (done) {
exec(`${BIN_EXEC} --compiler-host tests/hello-world`, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('Hello, world!\n')

return done()
})
})

it('should give ts error for invalid node_modules', function (done) {
exec(`${BIN_EXEC} --compiler-host --skip-ignore tests/from-node-modules`, function (err, stdout) {
if (err === null) return done('Expected an error')

expect(err.message).to.contain('Unable to compile file from external library')

return done()
})
})
})
})

describe('register', function () {
Expand Down
Loading

0 comments on commit 8834d64

Please sign in to comment.