smartgit/ts/smartgit.remote.ts

65 lines
2.0 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)){
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.remote.add expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
return done.promise;
};
if(!remoteNameArg) {
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.remote.add expects a valid remote name");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
return done.promise;
};
if(!remoteLinkArg) {
2016-07-05 01:47:38 +00:00
let err = new Error();
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
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)){
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.remote.list expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
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)){
2016-07-05 01:47:38 +00:00
let err = new Error("smartgit.remote.remove expects a valid git directory");
plugins.beautylog.error(err.message);
done.reject(err);
2016-07-04 01:49:24 +00:00
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
}