smartgit/ts/smartgit.remote.ts

60 lines
1.8 KiB
TypeScript
Raw Normal View History

2016-07-03 02:37:03 +00:00
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
2016-07-04 01:49:24 +00:00
let add = (dirPathArg,remoteNameArg:string, remoteLinkArg:string) => {
2016-07-03 02:37:03 +00:00
let done = plugins.Q.defer();
2016-07-04 01:49:24 +00:00
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.add expects a valid git directory");
done.reject();
return done.promise;
};
if(!remoteNameArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote name");
done.reject();
return done.promise;
};
if(!remoteLinkArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote link");
done.reject();
return done.promise;
};
// if everything is all right proceed
plugins.shelljs.exec(`cd ${dirPathArg} && git remote add ${remoteNameArg} ${remoteLinkArg}`);
remote.list(dirPathArg);
done.resolve();
return done.promise;
2016-07-03 02:37:03 +00:00
};
2016-07-04 01:49:24 +00:00
let check = (dirPathArg:string, remoteNameArg:string, remoteLinkArg) => {
}
2016-07-03 02:37:03 +00:00
2016-07-04 01:49:24 +00:00
let list = (dirPathArg) => {
let done = plugins.Q.defer();
let remotes = {};
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.list expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is all right proceed
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`).stdout;
done.resolve(remotes);
return done.promise;
};
let remove = (dirPathArg:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.remove expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is all right
2016-07-03 02:37:03 +00:00
}
export let remote = {
2016-07-04 01:49:24 +00:00
add: add,
list: list,
remove: remove
2016-07-03 02:37:03 +00:00
}