fix: accept extension batch separator

This commit is contained in:
Peter Steinberger
2026-05-25 03:34:22 +01:00
parent b43d312ec6
commit 3b23dc32b0
2 changed files with 12 additions and 3 deletions

View File

@@ -22,9 +22,11 @@ function printUsage() {
}
export function parseExtensionIds(rawArgs) {
const separatorIndex = rawArgs.indexOf("--");
const args = separatorIndex >= 0 ? rawArgs.slice(0, separatorIndex) : [...rawArgs];
const separatorPassthroughArgs = separatorIndex >= 0 ? rawArgs.slice(separatorIndex + 1) : [];
const normalizedArgs = rawArgs[0] === "--" ? rawArgs.slice(1) : rawArgs;
const separatorIndex = normalizedArgs.indexOf("--");
const args = separatorIndex >= 0 ? normalizedArgs.slice(0, separatorIndex) : [...normalizedArgs];
const separatorPassthroughArgs =
separatorIndex >= 0 ? normalizedArgs.slice(separatorIndex + 1) : [];
const extensionIds = [];
while (args[0] && !args[0].startsWith("-")) {

View File

@@ -718,6 +718,13 @@ describe("scripts/test-extension.mjs", () => {
expect([...parseExactVitestExcludePaths(["--exclude=extensions/**/*.test.ts"])]).toEqual([]);
});
it("accepts pnpm's leading argument separator before extension ids", () => {
expect(parseExtensionIds(["--", "telegram,slack", "--run"])).toEqual({
extensionIds: ["telegram", "slack"],
passthroughArgs: ["--run"],
});
});
it("fails explicitly requested extensions without tests by default", () => {
const extensionId = findExtensionWithoutTests();
const result = runScriptResult([extensionId]);