diff --git a/packages/cli/index.ts b/packages/cli/index.ts index eb29494c..9f5c80a1 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -18,7 +18,7 @@ import { glob } from "tinyglobby"; import ignore from "ignore"; import "./environments"; import { isBinaryFile } from "isbinaryfile"; -import { writePackageJSON, type PackageJson } from "pkg-types"; +import type { PackageJson } from "pkg-types"; import pkg from "./package.json" with { type: "json" }; import { createDefaultTemplate } from "./template"; @@ -251,13 +251,7 @@ const main = defineCommand({ console.warn("preparing template:", pJson.name); - const restore = await writeDeps( - templateDir, - pJsonContents, - pJson, - deps, - realDeps, - ); + const restore = writeDeps(templateDir, pJson, deps, realDeps); const gitignorePath = path.join(templateDir, ".gitignore"); const ig = ignore().add("node_modules").add(".git"); @@ -334,10 +328,7 @@ const main = defineCommand({ continue; } - restoreMap.set( - p, - await writeDeps(p, pJsonContents, pJson, deps, realDeps), - ); + restoreMap.set(p, await writeDeps(p, pJson, deps, realDeps)); } const shasums: Record = {}; @@ -552,9 +543,8 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) { return { filename, shasum }; } -async function writeDeps( +function writeDeps( p: string, - pJsonContents: string, pJson: PackageJson, deps: Map, realDeps: Map | null, @@ -569,9 +559,7 @@ async function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - await writePackageJSON(pJsonPath, pJson); - - return () => fs.writeFile(pJsonPath, pJsonContents); + return () => fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); } function hijackDeps(