import assert from "node:assert/strict"; import { mkdtemp, mkdir, readFile, rm } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; import { run } from "../dist/process.js"; const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); test("keeps Gradle worker paths compatible with Windows JDK 17", async () => { const gradleProperties = await readFile( path.join(repositoryRoot, "templates", "base", "gradle.properties"), "utf8", ); const buildGradle = await readFile( path.join(repositoryRoot, "templates", "base", "build.gradle"), "utf8", ); assert.doesNotMatch( gradleProperties, /org\.gradle\.jvmargs=.*-Dfile\.encoding=/, "Gradle daemon encoding must remain platform-compatible for worker classpath files", ); assert.match(buildGradle, /tasks\.withType\(JavaCompile\)[\s\S]*options\.encoding = 'UTF-8'/); assert.match(buildGradle, /tasks\.withType\(Test\)[\s\S]*jvmArgs '-Dfile\.encoding=UTF-8'/); assert.match(buildGradle, /tasks\.withType\(JavaExec\)[\s\S]*jvmArgs '-Dfile\.encoding=UTF-8'/); }); test("runs a child process from a Korean path containing spaces", async (t) => { const root = await mkdtemp(path.join(os.tmpdir(), "kri-create-spring-한글 공백-")); const targetDir = path.join(root, "생성 프로젝트"); await mkdir(targetDir, { recursive: true }); t.after(() => rm(root, { recursive: true, force: true })); const markerName = "실행 결과.txt"; const script = `require("node:fs").writeFileSync(${JSON.stringify(markerName)}, process.cwd(), "utf8")`; const nodeCommand = process.platform === "win32" ? path.basename(process.execPath) : process.execPath; await run(nodeCommand, ["-e", script], targetDir); assert.equal(await readFile(path.join(targetDir, markerName), "utf8"), targetDir); });