* Copy templates/start.sh and templates/start.bat to workDir.
(workDir: string)
| 33 | * Copy templates/start.sh and templates/start.bat to workDir. |
| 34 | */ |
| 35 | function copyStartTemplates(workDir: string): void { |
| 36 | const templateDir = path.resolve( |
| 37 | new URL("../templates", import.meta.url).pathname, |
| 38 | ); |
| 39 | |
| 40 | for (const file of ["start.sh", "start.bat"]) { |
| 41 | const src = path.join(templateDir, file); |
| 42 | const dest = path.join(workDir, file); |
| 43 | if (fs.existsSync(src)) { |
| 44 | fs.copyFileSync(src, dest); |
| 45 | if (file === "start.sh") { |
| 46 | fs.chmodSync(dest, 0o755); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | export async function runCommand(directory?: string): Promise<void> { |
| 53 | const workDir = directory ? path.resolve(directory) : process.cwd(); |