Skip to content

Commit 722924e

Browse files
committed
feat(tools): lint existence of exports
1 parent 2da40c6 commit 722924e

File tree

1 file changed

+19
-0
lines changed
  • tools/pfe-tools/cli/commands

1 file changed

+19
-0
lines changed

tools/pfe-tools/cli/commands/lint.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export async function handler(argv: Opts) {
3737

3838
const fixed = packageJson;
3939
const missing = new Map();
40+
const noTarget = new Map();
41+
4042
for (const entryPoint of entryPoints) {
4143
const js = entryPoint.replace(/\.ts$/, '.js');
4244
if (packageJson.exports[js] !== js) {
@@ -45,6 +47,12 @@ export async function handler(argv: Opts) {
4547
fixed.exports[js] = js;
4648
}
4749

50+
for (const [k, target] of Object.entries(fixed.exports) as [string, string][]) {
51+
if (!(await exists(join(pkgDir, target)))) {
52+
noTarget.set(k, target);
53+
}
54+
}
55+
4856
if (argv.fix) {
4957
await writeFile(PACKAGE_JSON_PATH, `${JSON.stringify(packageJson, null, 2)}\n\n`, 'utf-8');
5058
return;
@@ -56,6 +64,17 @@ export async function handler(argv: Opts) {
5664
console.log(chalk.red`missing export`, x);
5765
}
5866
}
67+
}
68+
69+
if (noTarget.size) {
70+
if (!argv.quiet) {
71+
for (const [k, x] of noTarget) {
72+
console.log(`${chalk.red`target`} ${chalk.yellow(x)} for export ${chalk.blue(k)} ${chalk.red`doesn't exist`}`);
73+
}
74+
}
75+
}
76+
77+
if (missing.size || noTarget.size) {
5978
process.exit(1);
6079
}
6180
}

0 commit comments

Comments
 (0)