Skip to content

Commit

Permalink
feat: use tsc from PATH if available
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 21, 2019
1 parent 6a3d461 commit 155710d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/targets/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export default async function build({ root, output, report }: Input) {

report.info(`Generating type definitions with ${chalk.blue('tsc')}`);

const tsc =
path.join(root, 'node_modules', '.bin', 'tsc') +
(platform() === 'win32' ? '.cmd' : '');

const tsconfig = path.join(root, 'tsconfig.json');

try {
Expand Down Expand Up @@ -57,6 +53,14 @@ export default async function build({ root, output, report }: Input) {
}
}

let tsc =
path.join(root, 'node_modules', '.bin', 'tsc') +
(platform() === 'win32' ? '.cmd' : '');

if (!await fs.pathExists(tsc)) {
tsc = child_process.execSync('which tsc').toString('utf-8').trim();
}

if (await fs.pathExists(tsc)) {
child_process.execFileSync(tsc, [
'--pretty',
Expand All @@ -75,7 +79,7 @@ export default async function build({ root, output, report }: Input) {
'tsc'
)} binary doesn't seem to be installed under ${chalk.blue(
'node_modules'
)}. Make sure you have added ${chalk.blue(
)} or present in $PATH. Make sure you have added ${chalk.blue(
'typescript'
)} to your ${chalk.blue('devDependencies')}.`
);
Expand Down

0 comments on commit 155710d

Please sign in to comment.