smartgit/ts/smartgit.commit.ts

16 lines
599 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-03-30 23:59:45 +00:00
2016-07-03 02:03:15 +00:00
export let commit = (dirPathArg:string,commitMessage:string) => {
let done = plugins.Q.defer();
2016-07-03 02:37:03 +00:00
if(!helpers.isGitDirectory(dirPathArg)){
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.commit expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-03 02:03:15 +00:00
return done.promise;
};
// if everything is all right proceed
2016-07-03 22:00:04 +00:00
plugins.shelljs.exec(`(cd ${dirPathArg} && git commit -m "${commitMessage}")`);
done.resolve();
return done.promise;
2016-03-30 23:59:45 +00:00
};