From 518c25003607497bfee4652919b3bf19646991e7 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 6 Jun 2021 02:32:51 -0400 Subject: [PATCH] Put "ts-node" object at the top of `--showConfig` output (#1355) * Put "ts-node" at the top of `--showConfig` output * update test to match new behavior * Fix lint failure --- src/bin.ts | 22 ++++++++++++---------- src/test/index.spec.ts | 12 ++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/bin.ts b/src/bin.ts index 9eef1b67c..811f942be 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -213,16 +213,18 @@ export function main( ); process.exit(1); } - const json = ts.convertToTSConfig( - service.config, - service.configFilePath ?? join(cwd, 'ts-node-implicit-tsconfig.json'), - service.ts.sys - ); - json['ts-node'] = { - ...service.options, - experimentalEsmLoader: undefined, - compilerOptions: undefined, - project: service.configFilePath ?? service.options.project, + const json = { + ['ts-node']: { + ...service.options, + experimentalEsmLoader: undefined, + compilerOptions: undefined, + project: service.configFilePath ?? service.options.project, + }, + ...ts.convertToTSConfig( + service.config, + service.configFilePath ?? join(cwd, 'ts-node-implicit-tsconfig.json'), + service.ts.sys + ), }; console.log( // Assumes that all configuration options which can possibly be specified via the CLI are JSON-compatible. diff --git a/src/test/index.spec.ts b/src/test/index.spec.ts index 8e14bda9a..9cc7800db 100644 --- a/src/test/index.spec.ts +++ b/src/test/index.spec.ts @@ -888,6 +888,12 @@ test.suite('ts-node', (test) => { stdout, JSON.stringify( { + 'ts-node': { + cwd: native(`${ROOT_DIR}/tests`), + projectSearchDir: native(`${ROOT_DIR}/tests`), + project: native(`${ROOT_DIR}/tests/tsconfig.json`), + require: [], + }, compilerOptions: { target: 'es6', jsx: 'react', @@ -904,12 +910,6 @@ test.suite('ts-node', (test) => { outDir: './.ts-node', module: 'commonjs', }, - 'ts-node': { - cwd: native(`${ROOT_DIR}/tests`), - projectSearchDir: native(`${ROOT_DIR}/tests`), - project: native(`${ROOT_DIR}/tests/tsconfig.json`), - require: [], - }, }, null, 2