Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(browser): retain multiline conditional command values [C7,O5]

Corey Olsonf2d8a71e2d2c
diff --git a/src/browser-launch-source.js b/src/browser-launch-source.js
index ffe5c9b9..8e423659 100644
--- a/src/browser-launch-source.js
+++ b/src/browser-launch-source.js
@@ -101,12 +101,18 @@ function unresolvedMemberCommand(expression) {
/** End one expression without consuming another argument or a surrounding function body. */
function expressionEnd(code, start, newlineEnds = true) {
let end = start;
- while (end < code.length && !';,)]}'.includes(code[end]) && (!newlineEnds || code[end] !== '\n')) {
+ let conditional = 0;
+ while (end < code.length && !';,)]}'.includes(code[end])) {
+ if (newlineEnds && code[end] === '\n' && !conditional && !code.slice(end + 1).trimStart().startsWith('?')) break;
if ('([{'.includes(code[end])) {
const close = closing(code, end);
if (close === null) return null;
end = close + 1;
- } else end += 1;
+ } else {
+ if (code[end] === '?' && !['?', '.'].includes(code[end + 1]) && code[end - 1] !== '?') conditional += 1;
+ else if (code[end] === ':' && conditional) conditional -= 1;
+ end += 1;
+ }
}
return end;
}
diff --git a/test/test-resources.test.js b/test/test-resources.test.js
index e9554475..6bd57f27 100644
--- a/test/test-resources.test.js
+++ b/test/test-resources.test.js
@@ -574,6 +574,7 @@ test('process member commands retain property assignments and unresolved targets
'test/namespace-key-command.test.js': "import * as child from 'node:child_process'; export function run(options) { return child['spawnSync'](options.command, []); }",
'test/conditional-command.test.js': imports + "export function run(options) { return spawnSync(options.enabled ? options.command : 'git', []); }",
'test/conditional-data.test.js': imports + "const executable = process.platform === 'darwin' ? '/usr/sbin/lsof' : process.platform === 'linux' ? '/usr/bin/lsof' : null; spawnSync(executable, []);",
+ 'test/conditional-lines-data.test.js': imports + "const executable = process.platform === 'darwin' ? '/usr/sbin/lsof'\n : process.platform === 'linux' ? '/usr/bin/lsof' : null; spawnSync(executable, []);",
'test/property-data.test.js': imports + "const options = {}; options.command = 'google-chrome'; spawnSync('git', ['status']);",
});
for (const name of ['dot-command', 'spaced-command', 'literal-key-command', 'computed-command', 'unresolved-command',
@@ -585,6 +586,8 @@ test('process member commands retain property assignments and unresolved targets
'an unused property value does not taint a literal Git command');
assert.equal(await testsNeedBrowser(root, ['test/conditional-data.test.js'], { byLaunch: true }), false,
'a platform predicate does not become one of the fixed executable values');
+ assert.equal(await testsNeedBrowser(root, ['test/conditional-lines-data.test.js'], { byLaunch: true }), false,
+ 'a multiline platform predicate retains both fixed executable branches');
assert.equal(await testsNeedBrowser(root, ['test/property-data.test.js'], { byLaunch: false }), true,
'default admission remains conservative');
});