@vitejs/release-scripts 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare function publish(options: {
2
- defaultPackage: string;
2
+ defaultPackage?: string;
3
3
  getPkgDir?: (pkg: string) => string;
4
4
  /**
5
5
  * Enables npm package provenance https://docs.npmjs.com/generating-provenance-statements
package/dist/index.js CHANGED
@@ -116,9 +116,19 @@ async function publishPackage(pkgDir, tag, provenance, packageManager = "npm") {
116
116
  }
117
117
  async function getActiveVersion(npmName) {
118
118
  try {
119
- return (await run("npm", ["info", npmName, "version"], { stdio: "pipe" })).stdout;
119
+ const { stdout } = await run(
120
+ "npm",
121
+ ["info", npmName, "version", "--json"],
122
+ { stdio: "pipe" }
123
+ );
124
+ return JSON.parse(stdout);
120
125
  } catch (e) {
121
- if (e.stderr.startsWith("npm ERR! code E404")) return;
126
+ if (e.stdout) {
127
+ const stdout = JSON.parse(e.stdout);
128
+ if (stdout.error.code === "E404") {
129
+ return;
130
+ }
131
+ }
122
132
  throw e;
123
133
  }
124
134
  }
@@ -137,6 +147,10 @@ var publish = async ({
137
147
  if (tag.includes("@")) [pkgName, version] = tag.split("@");
138
148
  else version = tag;
139
149
  if (version.startsWith("v")) version = version.slice(1);
150
+ if (pkgName === void 0)
151
+ throw new Error(
152
+ `Package name should be specified in tag "${tag}" when defaultPackage is not set`
153
+ );
140
154
  const { pkg, pkgDir } = getPackageInfo(pkgName, getPkgDir);
141
155
  if (pkg.version !== version)
142
156
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/release-scripts",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "@vitejs release scripts",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",