Comparing version
{ | ||
"name": "bump-npm", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "bump package version and publish", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,4 +18,17 @@ #!/usr/bin/env node | ||
const currentVersion = packageJson.version; | ||
const dependencies = packageJson.dependencies; | ||
const devDependencies = packageJson.devDependencies; | ||
const peerDependencies = packageJson.peerDependencies; | ||
function updateVersionNumber(version) { | ||
function updateJson(version, devAsPeer, rewind = false) { | ||
if (rewind && devAsPeer) { | ||
packageJson.dependencies = dependencies; | ||
packageJson.devDependencies = devDependencies; | ||
packageJson.peerDependencies = peerDependencies; | ||
} else if (devAsPeer) { | ||
packageJson.peerDependencies = packageJson.peerDependencies || []; | ||
packageJson.peerDependencies.push(...packageJson.dependencies); | ||
packageJson.dependencies = undefined; | ||
packageJson.devDependencies = undefined; | ||
} | ||
packageJson.version = version; | ||
@@ -44,3 +57,3 @@ fs.writeFileSync(fileName, JSON.stringify(packageJson, null, 2)); | ||
updateVersionNumber( | ||
updateJson( | ||
semver.inc( | ||
@@ -51,3 +64,4 @@ currentVersion, | ||
settings.prefix | ||
) | ||
), | ||
args.deptopeer | ||
); | ||
@@ -58,3 +72,3 @@ | ||
if (stderr) { | ||
updateVersionNumber(currentVersion); | ||
updateJson(currentVersion, args.deptopeer, true); | ||
throw stderr; | ||
@@ -61,0 +75,0 @@ } else { |
3271
25.13%82
20.59%