mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-26 11:12:53 +00:00
fix(migrate): preserve direct port arithmetic
This commit is contained in:
@@ -158,6 +158,9 @@ test("preserves literal or escaped Conductor names and rewrites active variables
|
||||
bare: { command: "printf CONDUCTOR_PORT" },
|
||||
heredoc: { command: "cat <<'EOF'\n$CONDUCTOR_PORT\nEOF" },
|
||||
active: { command: "printf \"'$CONDUCTOR_PORT'\"" },
|
||||
arithmeticDirect: { command: "serve --port $(( $CONDUCTOR_PORT ))" },
|
||||
arithmeticBraced: { command: "serve --port $(( ${CONDUCTOR_PORT} ))" },
|
||||
arithmeticOffset: { command: "serve --port $(( CONDUCTOR_PORT + 1 ))" },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -166,6 +169,8 @@ test("preserves literal or escaped Conductor names and rewrites active variables
|
||||
worktree: { setup: "printf '%s\\n' '$CONDUCTOR_WORKSPACE_PATH'" },
|
||||
scripts: {
|
||||
active: { command: "printf \"'$PASEO_PORT'\"", type: "service" },
|
||||
arithmeticBraced: { command: "serve --port $(( ${PASEO_PORT} ))", type: "service" },
|
||||
arithmeticDirect: { command: "serve --port $(( $PASEO_PORT ))", type: "service" },
|
||||
bare: { command: "printf CONDUCTOR_PORT" },
|
||||
escaped: { command: "printf \\$CONDUCTOR_PORT" },
|
||||
escapedDouble: { command: 'printf "\\$CONDUCTOR_PORT"' },
|
||||
@@ -176,6 +181,12 @@ test("preserves literal or escaped Conductor names and rewrites active variables
|
||||
level: "warning",
|
||||
message: "scripts.heredoc: Here-document commands are not imported.",
|
||||
});
|
||||
expect(inspected.notices).toContainEqual({
|
||||
code: "conductor-setting-unsupported",
|
||||
level: "warning",
|
||||
message:
|
||||
"scripts.arithmeticOffset.port_arithmetic: Conductor port arithmetic is not imported because Paseo reserves one service port.",
|
||||
});
|
||||
});
|
||||
|
||||
test("skips cwd scripts on Windows instead of emitting POSIX shell syntax", () => {
|
||||
|
||||
@@ -703,10 +703,11 @@ function containsArithmeticVariable(command: string, name: string): boolean {
|
||||
|
||||
function containsArithmeticVariableOperation(command: string, name: string): boolean {
|
||||
const identifier = new RegExp(`(^|[^A-Za-z0-9_])${name}(?![A-Za-z0-9_])`);
|
||||
const directVariable = new RegExp(`^(?:${name}|\\$${name}|\\$\\{${name}\\})$`);
|
||||
let found = false;
|
||||
forEachActiveArithmetic(command, (value) => {
|
||||
const body = value.trim();
|
||||
if (identifier.test(body) && body !== name) found = true;
|
||||
if (identifier.test(body) && !directVariable.test(body)) found = true;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user