From 0fc4478b2afc2a5d68b7cdeb167f0cc8ab4141bf Mon Sep 17 00:00:00 2001 From: Derk Nolte Date: Tue, 24 Mar 2020 12:39:28 +0100 Subject: [PATCH 1/5] feat: added tsc path option for typescript target --- src/targets/typescript.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/targets/typescript.ts b/src/targets/typescript.ts index 76926da4c..a86c71ebe 100644 --- a/src/targets/typescript.ts +++ b/src/targets/typescript.ts @@ -8,7 +8,7 @@ import { platform } from 'os'; import { Input } from '../types'; type Options = Input & { - options?: { project?: string }; + options?: { project?: string; tsc?: string }; }; export default async function build({ @@ -78,9 +78,10 @@ export default async function build({ ); } - let tsc = - path.join(root, 'node_modules', '.bin', 'tsc') + - (platform() === 'win32' ? '.cmd' : ''); + const tscPath = options?.tsc + ? options.tsc + : path.join(root, 'node_modules', '.bin', 'tsc'); + let tsc = tscPath + (platform() === 'win32' ? '.cmd' : ''); if (!(await fs.pathExists(tsc))) { tsc = spawn From f58db1ea3372ec35370d34f84efb4ec5d5565401 Mon Sep 17 00:00:00 2001 From: Derk Nolte Date: Tue, 24 Mar 2020 12:44:41 +0100 Subject: [PATCH 2/5] fix: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e3825695..5b2c9e81e 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Example: Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/). -By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option. +By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option. Furthermore, the tsc binary will be resolved to ./node_modules/.bin/tsc. Use the `tsc` option to sepcify a different path. Example: From 6faa623912cd5cae99b219555f125ab3e5e1ef44 Mon Sep 17 00:00:00 2001 From: Derk Nolte Date: Sat, 28 Mar 2020 07:04:29 +0100 Subject: [PATCH 3/5] fix: incorporated feedback --- src/targets/typescript.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/targets/typescript.ts b/src/targets/typescript.ts index a86c71ebe..f6714c5b1 100644 --- a/src/targets/typescript.ts +++ b/src/targets/typescript.ts @@ -78,10 +78,9 @@ export default async function build({ ); } - const tscPath = options?.tsc - ? options.tsc - : path.join(root, 'node_modules', '.bin', 'tsc'); - let tsc = tscPath + (platform() === 'win32' ? '.cmd' : ''); + let tsc = options?.tsc + ? path.resolve(root, options.tsc) + : path.join(root, 'node_module') + (platform() === 'win32' ? '.cmd' : ''); if (!(await fs.pathExists(tsc))) { tsc = spawn From 7335dff83532284cf587730a65d64642032d76e0 Mon Sep 17 00:00:00 2001 From: Derk Nolte Date: Sat, 28 Mar 2020 07:23:52 +0100 Subject: [PATCH 4/5] fix: updated error/warning message --- src/targets/typescript.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/targets/typescript.ts b/src/targets/typescript.ts index f6714c5b1..b82280eff 100644 --- a/src/targets/typescript.ts +++ b/src/targets/typescript.ts @@ -93,7 +93,9 @@ export default async function build({ 'tsc' )}. Consider adding ${chalk.blue('typescript')} to your ${chalk.blue( 'devDependencies' - )} instead.` + )} or specifying the ${chalk.blue( + 'tsc' + )} option for the typescript target.` ); } @@ -127,7 +129,9 @@ export default async function build({ 'node_modules' )} or present in $PATH. Make sure you have added ${chalk.blue( 'typescript' - )} to your ${chalk.blue('devDependencies')}.` + )} to your ${chalk.blue('devDependencies')} or specify the ${chalk.blue( + 'tsc' + )} option for typescript.` ); } } catch (e) { From 99569b2fc5c35bf0c5d6dbde6b196c8a85b90ade Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Fri, 8 May 2020 01:31:45 +0200 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: James George --- README.md | 2 +- src/targets/typescript.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b2c9e81e..1991e6866 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Example: Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/). -By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option. Furthermore, the tsc binary will be resolved to ./node_modules/.bin/tsc. Use the `tsc` option to sepcify a different path. +By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option. Furthermore, the tsc binary will be resolved to ./node_modules/.bin/tsc. Use the `tsc` option to specify a different path. Example: diff --git a/src/targets/typescript.ts b/src/targets/typescript.ts index b82280eff..14552aebb 100644 --- a/src/targets/typescript.ts +++ b/src/targets/typescript.ts @@ -80,7 +80,7 @@ export default async function build({ let tsc = options?.tsc ? path.resolve(root, options.tsc) - : path.join(root, 'node_module') + (platform() === 'win32' ? '.cmd' : ''); + : path.join(root, 'node_modules') + (platform() === 'win32' ? '.cmd' : ''); if (!(await fs.pathExists(tsc))) { tsc = spawn