smartgit/ts/smartgit.pull.ts

16 lines
630 B
TypeScript

import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
export let pull = (dirPathArg:string,sourceArg:string = "", branchArg:string = "") => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
let err = new Error("smartgit.pull expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
return done.promise;
};
// if everything is allright proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git pull ${sourceArg} ${branchArg})`);
done.resolve(dirPathArg);
return done.promise;
};