Files
scriptc/tests/corpus/unicode-process-argv.ts
Chris Tate 806b96d32b feat(compiler): own the TypeScript server from native clients
- Launch and manage TypeScript server processes through a portable native FFI boundary.
- Share the production session API between Node and statically compiled clients.
- Preserve Unicode command-line arguments and release server resources on every exit path.
2026-09-28 09:54:18 -05:00

15 lines
651 B
TypeScript

import { spawnSync } from "node:child_process";
if (process.argv[2] === "echo") {
const args = process.argv;
console.log(args === process.argv);
console.log(JSON.stringify(args.slice(3)));
args.push("追加");
console.log(process.argv[process.argv.length - 1]);
} else {
const argumentsToEcho = ["", "héllo", "中文", "🌍", "a b", 'double"quote', "end\\", 'slashes\\\\"quote', "&;$(hello)`test'", "line\nbreak", "tab\targ"];
const result = spawnSync(process.execPath, [process.argv[1]!, "echo", ...argumentsToEcho], { encoding: "utf8" });
console.log(result.status, result.stderr === "");
process.stdout.write(result.stdout);
}