Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
automatically set package.json version if one isn't defined
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Mar 19, 2024
1 parent 61436e8 commit 9e845b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/cmd-fns/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ export const publish = async (ctx: AppContext, args: any) => {
await readFileSync(Path.join(ctx.cwd, "package.json"), "utf-8")
)

if (!packageJson.version) {
console.log(kleur.yellow("No version found in package.json"))
console.log(kleur.green("Setting package.json version to 0.0.1"))
packageJson.version = "0.0.1"
await fs.writeFile(
Path.join(ctx.cwd, "package.json"),
JSON.stringify(packageJson, null, 2)
)
}

await esbuild.build({
entryPoints: ["index.ts"], // TODO dynamically determine entrypoint
bundle: true,
Expand Down

0 comments on commit 9e845b5

Please sign in to comment.