Skip to content

Commit 05a53a5

Browse files
authored
feat: add option to specify tsc path (#31)
1 parent 6447115 commit 05a53a5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Example:
172172

173173
Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/).
174174

175-
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.
175+
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.
176176

177177
Example:
178178

src/targets/typescript.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { platform } from 'os';
88
import { Input } from '../types';
99

1010
type Options = Input & {
11-
options?: { project?: string };
11+
options?: { project?: string; tsc?: string };
1212
};
1313

1414
export default async function build({
@@ -78,9 +78,9 @@ export default async function build({
7878
);
7979
}
8080

81-
let tsc =
82-
path.join(root, 'node_modules', '.bin', 'tsc') +
83-
(platform() === 'win32' ? '.cmd' : '');
81+
let tsc = options?.tsc
82+
? path.resolve(root, options.tsc)
83+
: path.join(root, 'node_modules') + (platform() === 'win32' ? '.cmd' : '');
8484

8585
if (!(await fs.pathExists(tsc))) {
8686
tsc = spawn.sync('which', ['tsc']).stdout.toString().trim();
@@ -90,7 +90,9 @@ export default async function build({
9090
'tsc'
9191
)}. Consider adding ${chalk.blue('typescript')} to your ${chalk.blue(
9292
'devDependencies'
93-
)} instead.`
93+
)} or specifying the ${chalk.blue(
94+
'tsc'
95+
)} option for the typescript target.`
9496
);
9597
}
9698

@@ -124,7 +126,9 @@ export default async function build({
124126
'node_modules'
125127
)} or present in $PATH. Make sure you have added ${chalk.blue(
126128
'typescript'
127-
)} to your ${chalk.blue('devDependencies')}.`
129+
)} to your ${chalk.blue('devDependencies')} or specify the ${chalk.blue(
130+
'tsc'
131+
)} option for typescript.`
128132
);
129133
}
130134
} catch (e) {

0 commit comments

Comments
 (0)