smartgit/ts/smartgit.pull.ts

16 lines
630 B
TypeScript
Raw Normal View History

2016-07-03 02:03:15 +00:00
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
2016-07-03 02:37:03 +00:00
2016-07-03 02:03:15 +00:00
export let pull = (dirPathArg:string,sourceArg:string = "", branchArg:string = "") => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.pull expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
return done.promise;
2016-07-03 02:03:15 +00:00
};
2016-07-03 22:13:32 +00:00
// if everything is allright proceed
2016-07-03 02:03:15 +00:00
plugins.shelljs.exec(`(cd ${dirPathArg} && git pull ${sourceArg} ${branchArg})`);
done.resolve(dirPathArg);
return done.promise;
};