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
15 changes: 13 additions & 2 deletions scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,25 @@ function readToken() {
}

try {
for (const pkg of ORDER) publish(pkg);
for (const pkg of ORDER) await publish(pkg);
} finally {
if (tokenDir) rmSync(tokenDir, { recursive: true, force: true });
}

function publish(pkg) {
// A release usually bumps one package; the other is already on npm at its version, and
// publishing it again would fail after the first package went out.
async function published(name, version) {
const res = await fetch(`https://registry.npmjs.org/${name.replace('/', '%2f')}/${version}`);
return res.ok;
}

async function publish(pkg) {
const version = JSON.parse(readFileSync(join(root, pkg.dir, 'package.json'), 'utf8')).version;
process.stdout.write(`\n${pkg.name}@${version} — ${pkg.why}\n`);
if (await published(pkg.name, version)) {
process.stdout.write(' already on npm, skipped\n');
return;
}
if (!yes) {
process.stdout.write(
` would run: pnpm --filter ${pkg.name} publish --access public${tag ? ` --tag ${tag}` : ''}\n`,
Expand Down
Loading