/
index.js
31 lines (25 loc) · 877 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
'use strict';
const child_process = require('child_process');
const exec = child_process.exec;
function bumpVersion(pathToDir, type, extraArgs) {
return new Promise((resolve, reject) => {
//construct the command
//eg: npm version major --force
exec(`npm version ${type} ${extraArgs}`, { cwd: pathToDir }, (error, stdout, stderr) => {
if (error) { reject(error); return; } resolve({ stdout: stdout, pathToDir: pathToDir });
});
});
}
function publish(pathToDir, extraArgs) {
return new Promise((resolve, reject) => {
//construct the command
//eg: npm publish --tag alpha
exec(`npm publish ${extraArgs}`, { cwd: pathToDir }, (error, stdout, stderr) => {
if (error) { reject(error); return; } resolve({ stdout: stdout, pathToDir: pathToDir });
});
});
}
module.exports = {
bumpVersion: bumpVersion,
publish: publish
}