Skip to content

Commit 3673ee9

Browse files
committed
fix: validate explicit project config filenames
1 parent 32bb5ea commit 3673ee9

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

scripts/__tests__/rslib-harness.test.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,39 @@ export default {
655655
});
656656
});
657657

658+
test('resolveProjects rejects unsupported explicit project config files', async () => {
659+
await withTempDir(async (root) => {
660+
writeRslibProject(root, 'packages/pkg-a', 'pkg-a');
661+
writeFile(
662+
join(root, 'packages/pkg-a/custom.config.ts'),
663+
'export default {};\n',
664+
);
665+
writeFile(
666+
join(root, 'rslib.harness.config.mjs'),
667+
`
668+
export default {
669+
projects: [
670+
{
671+
root: './packages/pkg-a',
672+
config: './custom.config.ts',
673+
},
674+
],
675+
};
676+
`,
677+
);
678+
679+
await assert.rejects(
680+
() =>
681+
resolveProjects({
682+
harnessConfigPath: join(root, 'rslib.harness.config.mjs'),
683+
rootDir: root,
684+
projectFilters: [],
685+
}),
686+
/is not a supported rslib\.config\.\* file/,
687+
);
688+
});
689+
});
690+
658691
test('validateCommandGuards rejects multi-project watch/mf-dev mode', () => {
659692
assert.throws(
660693
() =>

scripts/rslib-harness.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,12 @@ async function resolveProjects({ harnessConfigPath, rootDir, projectFilters }) {
731731
);
732732
}
733733

734+
if (!isRslibConfigFile(explicitConfigFile)) {
735+
throw new Error(
736+
`Project config path "${explicitConfigFile}" is not a supported rslib.config.* file (from ${sourceConfig}).`,
737+
);
738+
}
739+
734740
await addProject({
735741
name: entry.name,
736742
projectRoot: dirname(explicitConfigFile),

0 commit comments

Comments
 (0)