feat(pre): add initial version of command

This commit is contained in:
Stephan Bönnemann
2015-02-02 04:13:21 +01:00
parent f31a5dfd04
commit 0ee9cc31e9
5 changed files with 90 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
'use strict'
var fs = require('fs')
var semver = require('semver')
var type = require('../lib/type')
var version = require('../lib/version')
module.exports = function (options, cb) {
type(function (err, type) {
if (err) return cb(err)
if (!type) return cb(null, null)
var path = './package.json'
var pkg = JSON.parse(fs.readFileSync(path))
version(pkg, function (err, version, unpublished) {
if (err) return cb(err)
pkg.version = unpublished ? '1.0.0' : semver.inc(version, type)
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2))
cb(null, pkg.version)
})
})
}