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) => {
|
2016-07-02 00:22:03 +00:00
|
|
|
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}")`);
|
2016-07-02 00:22:03 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
2016-03-30 23:59:45 +00:00
|
|
|
};
|