Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/cli.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ async function request(method, route, body, timeoutMs) {

// Starts the app in the background, with no window and without taking focus. False when it cannot be started here.
function launchApp() {
// Tests and scripts that must never start the real app set this.
if (process.env.AVENUE_SYNC_NO_LAUNCH) return false;
const { spawn } = require('node:child_process');
let command;
if (process.platform === 'darwin') {
Expand Down
9 changes: 8 additions & 1 deletion test/cli.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function withApp(overrides, run) {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-cli-'));
fs.writeFileSync(path.join(dir, 'api-port'), String(port));
fs.writeFileSync(path.join(dir, 'api-token'), TOKEN);
try { await run({ dir, calls, env: { ...process.env, AVENUE_SYNC_DATA: dir } }); } finally { await api.close(); }
try { await run({ dir, calls, env: { ...process.env, AVENUE_SYNC_DATA: dir, AVENUE_SYNC_NO_LAUNCH: '1' } }); } finally { await api.close(); }
}

const cli = (env, ...args) => new Promise((resolve) => {
Expand Down Expand Up @@ -224,6 +224,13 @@ test('every tool schema names only real parameters and never exposes open', () =

// ---- Starting the app on demand ----

test('the real launcher refuses to start anything when AVENUE_SYNC_NO_LAUNCH is set', async () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-nolaunch-env-'));
const out = await cli({ ...process.env, AVENUE_SYNC_DATA: dir, AVENUE_SYNC_NO_LAUNCH: '1' }, 'status');
assert.equal(out.code, 2);
assert.match(out.stderr, /not running/);
});

test('with the app not running, a command starts it once in the background and then succeeds', async () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-launch-'));
process.env.AVENUE_SYNC_DATA = dir;
Expand Down
Loading