Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(cli): three review findings — gif+audio, pack collisions, piped help

Etienne Lescot9010dc5562a3
diff --git a/electron/cli/args.test.ts b/electron/cli/args.test.ts
index 3c00bc200..e33acb672 100644
--- a/electron/cli/args.test.ts
+++ b/electron/cli/args.test.ts
@@ -96,6 +96,10 @@ describe("parseCliArgs", () => {
expect(parse(["export", "a.openscreen", "--audio", "v.mp3", "--format", "gif"])).toMatchObject({
kind: "error",
});
+ // gif inferred from --out, with no explicit --format
+ expect(parse(["export", "a.openscreen", "--audio", "v.mp3", "-o", "out.gif"])).toMatchObject({
+ kind: "error",
+ });
expect(parse(["export", "a.openscreen", "--audio-offset", "-1"])).toMatchObject({
kind: "error",
});
diff --git a/electron/cli/args.ts b/electron/cli/args.ts
index a14d74b06..56fea1ee5 100644
--- a/electron/cli/args.ts
+++ b/electron/cli/args.ts
@@ -260,9 +260,6 @@ function parseExport(args: string[], cwd: string): CliCommand {
}
if (!request.projectPath) throw new Error("export requires a <project.openscreen> path");
- if (request.audioPath && request.format === "gif") {
- throw new Error("--audio is only supported for MP4 exports");
- }
if (request.outPath) {
const ext = path.extname(request.outPath).toLowerCase();
if (ext !== ".mp4" && ext !== ".gif") {
@@ -274,6 +271,10 @@ function parseExport(args: string[], cwd: string): CliCommand {
}
request.format = extFormat;
}
+ // After --out resolves the format, so `--audio … -o out.gif` is caught too.
+ if (request.audioPath && request.format === "gif") {
+ throw new Error("--audio is only supported for MP4 exports");
+ }
return request;
}
diff --git a/electron/cli/cliMain.ts b/electron/cli/cliMain.ts
index 941013108..611c3cae2 100644
--- a/electron/cli/cliMain.ts
+++ b/electron/cli/cliMain.ts
@@ -250,7 +250,13 @@ async function runPackCommand(projectPath: string, outDir: string, json: boolean
const copied: string[] = [];
const copyIn = async (sourcePath: string): Promise<string> => {
- const destination = path.join(outDir, path.basename(sourcePath));
+ const ext = path.extname(sourcePath);
+ const stem = path.basename(sourcePath, ext);
+ let destination = path.join(outDir, stem + ext);
+ // Screen and webcam can share a basename across directories; don't overwrite.
+ for (let n = 1; copied.includes(destination); n++) {
+ destination = path.join(outDir, `${stem}-${n}${ext}`);
+ }
if (path.resolve(sourcePath) !== path.resolve(destination)) {
await fs.copyFile(sourcePath, destination);
}
@@ -369,12 +375,12 @@ async function runInfoCommand(projectPath: string, json: boolean): Promise<numbe
export function runCli(command: CliCommand): void {
if (command.kind === "help") {
- process.stdout.write(CLI_USAGE);
+ safeWrite(process.stdout, CLI_USAGE);
app.exit(0);
return;
}
if (command.kind === "error") {
- process.stderr.write(`Error: ${command.message}\n\n${CLI_USAGE}`);
+ safeWrite(process.stderr, `Error: ${command.message}\n\n${CLI_USAGE}`);
app.exit(2);
return;
}