Skip to content

Commit b28e308

Browse files
chore: sanitize user-specific paths in command output and update documentation
1 parent 1791df5 commit b28e308

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docs/commands.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,11 @@ Options:
318318
--asset <mode> Asset type to download (auto, installer, exe) (default:
319319
"auto")
320320
--dir <path> Download directory (default:
321-
"C:\\Users\\ymc\\AppData\\Local\\CloudSQLCTL\\downloads\\updates")
321+
"<USER_HOME>\\AppData\\Local\\CloudSQLCTL\\downloads\\updates")
322322
--force Force update even if version is same or older
323323
--no-silent Run installer in interactive mode (installer only)
324324
--no-elevate Do not attempt to elevate privileges (installer only)
325325
--json Output status in JSON format
326326
-h, --help display help for command
327327
```
328+

tools/generate-docs.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execa } from 'execa';
22
import fs from 'fs-extra';
33
import path from 'path';
4+
import os from 'os';
45
import { fileURLToPath } from 'url';
56

67
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -9,9 +10,23 @@ const CLI_PATH = path.join(ROOT_DIR, 'dist', 'cli.cjs');
910
const DOCS_DIR = path.join(ROOT_DIR, 'docs');
1011
const DOCS_FILE = path.join(DOCS_DIR, 'commands.md');
1112

13+
const HOME_DIR = os.homedir();
14+
1215
async function runCli(args) {
1316
const { stdout } = await execa('node', [CLI_PATH, ...args]);
14-
return stdout;
17+
18+
// Sanitize output: replace user-specific paths with placeholders
19+
// This prevents CI failures due to different user names (e.g., ymc vs runneradmin)
20+
let sanitized = stdout;
21+
22+
const homeDir = os.homedir();
23+
const escapedHome = homeDir.replace(/\\/g, '\\\\');
24+
25+
// Replace various forms of the home directory path
26+
sanitized = sanitized.split(homeDir).join('<USER_HOME>');
27+
sanitized = sanitized.split(escapedHome).join('<USER_HOME>');
28+
29+
return sanitized;
1530
}
1631

1732
async function generateDocs() {

0 commit comments

Comments
 (0)