UNPKG

1.05 kBJavaScriptView Raw
1const path = require('path')
2const printError = require('./lib/print-error')
3
4const bump = require('./lib/lifecycles/bump')
5const changelog = require('./lib/lifecycles/changelog')
6const commit = require('./lib/lifecycles/commit')
7const tag = require('./lib/lifecycles/tag')
8
9module.exports = function standardVersion (argv) {
10 var pkgPath = path.resolve(process.cwd(), './package.json')
11 var pkg = require(pkgPath)
12 var newVersion = pkg.version
13 var defaults = require('./defaults')
14 var args = Object.assign({}, defaults, argv)
15
16 return Promise.resolve()
17 .then(() => {
18 return bump(args, pkg)
19 })
20 .then((_newVersion) => {
21 // if bump runs, it calculaes the new version that we
22 // should release at.
23 if (_newVersion) newVersion = _newVersion
24 return changelog(args, newVersion)
25 })
26 .then(() => {
27 return commit(args, newVersion)
28 })
29 .then(() => {
30 return tag(newVersion, pkg.private, args)
31 })
32 .catch((err) => {
33 printError(args, err.message)
34 throw err
35 })
36}