-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·45 lines (39 loc) · 915 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
const fs = require('fs')
const { spawn } = require('child_process')
const { program } = require('commander')
const { description, version } = require('./package.json')
program
.version(version)
.description(description)
.option('-p, --preid <id>', 'pre-release id', 'develop')
.option('-g, --git-tag-version', 'commit and tag the version change', false)
.option(
'-t, --tag <tag>',
'registers the published package with the given tag',
'next',
)
program.parse(process.argv)
fs.writeFileSync(
'.npmrc',
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`,
)
spawn(
'npm',
[
'version',
'prerelease',
'--preid',
program.preid,
'--git-tag-version',
program.gitTagVersion,
],
{
cwd: process.cwd(),
stdio: 'inherit',
},
)
spawn('npm', ['publish', '--tag', program.tag], {
cwd: process.cwd(),
stdio: 'inherit',
})