Skip to content

Commit 2e7b545

Browse files
committed
feat: support path to custom tsconfig for typescript
1 parent 010361f commit 2e7b545

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ yargs
317317
root,
318318
source: path.resolve(root, source as string),
319319
output: path.resolve(root, output as string, 'typescript'),
320+
options: targetOptions,
320321
report,
321322
});
322323
break;

src/targets/typescript.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ import JSON5 from 'json5';
77
import { platform } from 'os';
88
import { Input } from '../types';
99

10-
export default async function build({ root, output, report }: Input) {
10+
type Options = Input & {
11+
options?: { project?: string };
12+
};
13+
14+
export default async function build({
15+
root,
16+
output,
17+
report,
18+
options,
19+
}: Options) {
1120
report.info(
1221
`Cleaning up previous build at ${chalk.blue(path.relative(root, output))}`
1322
);
@@ -16,7 +25,8 @@ export default async function build({ root, output, report }: Input) {
1625

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

19-
const tsconfig = path.join(root, 'tsconfig.json');
28+
const project = options?.project ? options.project : 'tsconfig.json';
29+
const tsconfig = path.join(root, project);
2030

2131
try {
2232
if (await fs.pathExists(tsconfig)) {
@@ -48,7 +58,7 @@ export default async function build({ root, output, report }: Input) {
4858
if (conflicts.length) {
4959
report.warn(
5060
`Found following options in the config file which can conflict with the CLI options. Please remove them from ${chalk.blue(
51-
'tsconfig.json'
61+
project
5262
)}:${conflicts.reduce(
5363
(acc, curr) =>
5464
acc + `\n${chalk.gray('-')} ${chalk.yellow(curr)}`,
@@ -59,7 +69,7 @@ export default async function build({ root, output, report }: Input) {
5969
}
6070
} catch (e) {
6171
report.warn(
62-
`Couldn't parse 'tsconfig.json'. There might be validation errors.`
72+
`Couldn't parse '${project}'. There might be validation errors.`
6373
);
6474
}
6575
}
@@ -80,11 +90,15 @@ export default async function build({ root, output, report }: Input) {
8090
'--pretty',
8191
'--declaration',
8292
'--emitDeclarationOnly',
93+
'--project',
94+
project,
8395
'--outDir',
8496
output,
8597
]);
8698

87-
await del([path.join(output, 'tsconfig.tsbuildinfo')]);
99+
await del([
100+
path.join(output, project.replace(/\.json$/, '.tsbuildinfo')),
101+
]);
88102

89103
report.success(
90104
`Wrote definition files to ${chalk.blue(path.relative(root, output))}`

0 commit comments

Comments
 (0)