comb-cli
Version:
comb cli
36 lines (34 loc) • 977 B
JavaScript
const path = require('path');
const process = require('process');
const rootPath = process.cwd();
const cliOpt = require('../lib/config.json');
const targetPath = path.resolve(rootPath, cliOpt.project.tempDir, '../');
require('shelljs/global');
const colors = require('colors');
function execGit (cmd) {
return new Promise ((resolve, reject) => {
echo(`${cmd}`.yellow);
exec(`${cmd}`, function (code) {
if (0 === parseInt(code)) {
echo(`${cmd} done`.green);
resolve();
} else {
echo(`${cmd} fail`.red);
reject();
}
});
});
}
function push (msg) {
// cd(targetPath);
cd(rootPath);
execGit('git add .').then(() => {
execGit(`git commit -m "${msg}"`).then(() => {
execGit('git pull').then(() => {
execGit('git push');
});
});
});
}
module.exports = push;