Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,19 @@ jobs:
echo "::group::${package}"

# Skip previewing when the local version is already on the registry.
local_version="$(npm pkg get version --workspace "${package}" | node -e '
local_version="$(npm pkg get version --workspace "${package}" --json | node -e '
let input = "";
process.stdin.on("data", chunk => input += chunk);
process.stdin.on("end", () => {
// npm 11 prints {"<name>": "<version>"}; npm 12 needs --json and
// prints {"<name>": {"version": "<version>"}}. Accept both.
const parsed = JSON.parse(input);
const version = typeof parsed === "string" ? parsed : Object.values(parsed)[0];
let version = typeof parsed === "string" ? parsed : Object.values(parsed)[0];
if (version && typeof version === "object") version = version.version;
if (typeof version !== "string" || !version) {
console.error(`Could not read the version from: ${input}`);
process.exit(1);
}
process.stdout.write(version);
});
')"
Expand Down Expand Up @@ -164,12 +171,19 @@ jobs:
echo "::group::${package}"

# Skip publishing when the local version is already on the registry.
local_version="$(npm pkg get version --workspace "${package}" | node -e '
local_version="$(npm pkg get version --workspace "${package}" --json | node -e '
let input = "";
process.stdin.on("data", chunk => input += chunk);
process.stdin.on("end", () => {
// npm 11 prints {"<name>": "<version>"}; npm 12 needs --json and
// prints {"<name>": {"version": "<version>"}}. Accept both.
const parsed = JSON.parse(input);
const version = typeof parsed === "string" ? parsed : Object.values(parsed)[0];
let version = typeof parsed === "string" ? parsed : Object.values(parsed)[0];
if (version && typeof version === "object") version = version.version;
if (typeof version !== "string" || !version) {
console.error(`Could not read the version from: ${input}`);
process.exit(1);
}
process.stdout.write(version);
});
')"
Expand Down
Loading