fix: create parent dirs in script new and accept python as language alias

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-03-24 13:10:03 +00:00
co-authored by Claude Opus 4.5
parent 37886edda1
commit db4df60fb8
+9 -1
View File
@@ -1,7 +1,7 @@
import { GlobalOptions } from "../../types.ts";
import { requireLogin } from "../../core/auth.ts";
import { resolveWorkspace, validatePath } from "../../core/context.ts";
import { readFile, writeFile, stat } from "node:fs/promises";
import { readFile, writeFile, stat, mkdir } from "node:fs/promises";
import { Buffer } from "node:buffer";
import { colors } from "@cliffy/ansi/colors";
import { Command } from "@cliffy/command";
@@ -1078,6 +1078,11 @@ async function bootstrap(
return;
}
// normalize language aliases
if (language === ("python" as any)) {
language = "python3";
}
const scriptInitialCode = scriptBootstrapCode[language];
if (scriptInitialCode === undefined) {
throw new Error("Language unknown");
@@ -1118,6 +1123,9 @@ async function bootstrap(
yamlOptions
);
const parentDir = path.dirname(scriptCodeFileFullPath);
await mkdir(parentDir, { recursive: true });
await writeFile(scriptCodeFileFullPath, scriptInitialCode, {
flag: 'wx', encoding: 'utf-8',
});