发布 npm 包
使用pnpm publish发布包到 npm 仓库
sh
pnpm publish --tag 1.0.0 --access public --registry https://registry.npmjs.orgjs
const path = require('node:path')
const chalk = require('chalk')
const execa = require('execa')
const args = require('minimist')(process.argv.slice(2))
const targetVersion = args.v
const step = msg => console.log(chalk.cyan(msg))
const run = (bin, args, opts = {}) => execa(bin, args, { stdio: 'inherit', ...opts });
(async function main() {
step('\nPublishing package...')
await run(
'pnpm',
[
'publish',
'--tag',
targetVersion,
'--registry',
'https://registry.npmjs.org',
'--access',
'public',
],
{
cwd: path.resolve(__dirname),
stdio: 'pipe',
},
)
})()