From feae7b20b6de27812069b9303b3cf8a743d944c1 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Tue, 19 Feb 2019 10:11:48 -0800 Subject: [PATCH] fix: hide debug warning if typescript is not found Fixes https://github.com/oclif/config/issues/73 --- src/ts-node.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ts-node.ts b/src/ts-node.ts index 038825e0..a1d27313 100644 --- a/src/ts-node.ts +++ b/src/ts-node.ts @@ -5,13 +5,6 @@ import * as TSNode from 'ts-node' import Debug from './debug' const debug = Debug() -let typescript: typeof import('typescript') -try { - typescript = require('typescript') -} catch (ex) { - debug('Cannot find typescript', ex) -} - const tsconfigs: {[root: string]: TSConfig} = {} const rootDirs: string[] = [] const typeRoots = [`${__dirname}/../node_modules/@types`] @@ -65,6 +58,13 @@ function registerTSNode(root: string) { function loadTSConfig(root: string): TSConfig | undefined { const tsconfigPath = path.join(root, 'tsconfig.json') + let typescript: typeof import('typescript') | undefined + try { + typescript = require('typescript') + } catch { + // debug('Cannot find typescript', ex) + } + if (fs.existsSync(tsconfigPath) && typescript) { const tsconfig = typescript.parseConfigFileTextToJson( tsconfigPath,