enhanced-publish 1.1.1 → 1.1.3
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/index.js +17 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// @ts-check
|
|
4
|
+
|
|
3
5
|
const { spawn } = require("child_process")
|
|
4
6
|
const { readFileSync } = require("fs")
|
|
5
7
|
const pacote = require("pacote")
|
|
6
8
|
|
|
7
9
|
function getPackageInfo() {
|
|
8
|
-
const pJson = JSON.parse(readFileSync("./package.json"))
|
|
10
|
+
const pJson = JSON.parse(readFileSync("./package.json", "utf8"))
|
|
9
11
|
|
|
10
12
|
return {
|
|
11
13
|
name: pJson.name,
|
|
@@ -37,6 +39,19 @@ async function run() {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
const pkg = getPackageInfo()
|
|
42
|
+
|
|
43
|
+
const semverWithPreidRegex = /^\d+\.\d+\.\d+(?:-([a-z]+)(?:\.\d+)+)?$/
|
|
44
|
+
const semverMatches = semverWithPreidRegex.exec(pkg.version)
|
|
45
|
+
|
|
46
|
+
if (process.argv.includes("--only-prerelease")) {
|
|
47
|
+
console.log("Only prerelease packages will be published.")
|
|
48
|
+
|
|
49
|
+
if (!semverMatches || !semverMatches[1]) {
|
|
50
|
+
console.error(`The version '${pkg.version}' of package '${pkg.name}' is not a prerelease version, aborting.`)
|
|
51
|
+
process.exit(0)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
const isPublished = await existsPackageInRegistry(pkg)
|
|
41
56
|
|
|
42
57
|
if (process.argv.includes("--if-possible") && isPublished) {
|
|
@@ -48,15 +63,13 @@ async function run() {
|
|
|
48
63
|
args.splice(0, 2)
|
|
49
64
|
args = args.filter((arg) => !newFlags.includes(arg))
|
|
50
65
|
|
|
51
|
-
const semverWithPreidRegex = /^\d+\.\d+\.\d+(?:-([a-z]+)(?:\.\d+)+)?$/
|
|
52
|
-
const semverMatches = semverWithPreidRegex.exec(pkg.version)
|
|
53
66
|
if (process.argv.includes("--use-preid-as-tag") && semverMatches && semverMatches[1]) {
|
|
54
67
|
const preid = semverMatches[1]
|
|
55
68
|
args.push("--tag", preid)
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
const child = spawn("npm", ["publish", ...args], { stdio: "inherit" })
|
|
59
|
-
child.on("exit", (code) => process.exit(code))
|
|
72
|
+
child.on("exit", (code) => process.exit(code ?? 0))
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
run()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "enhanced-publish",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Npm publish command with lerna's from-package publish behaviour.",
|
|
5
5
|
"repository": "github:js-soft/enhanced-npm-publish",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"index.js"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pacote": "^
|
|
13
|
+
"pacote": "^18.0.0"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|