smartgit/ts/index.ts

29 lines
929 B
TypeScript
Raw Normal View History

2019-06-18 13:17:50 +00:00
import plugins = require('./smartgit.plugins');
2016-03-30 23:59:45 +00:00
2019-06-18 13:17:50 +00:00
import { GitRepo } from './smartgit.classes.gitrepo';
export { GitRepo };
2016-11-22 20:49:40 +00:00
/**
* creates a new GitRepo Instance after cloning a project
*/
2019-06-18 13:17:50 +00:00
export const createRepoFromClone = async (fromArg: string, toArg: string): Promise<GitRepo> => {
let done = q.defer<GitRepo>();
plugins.smartfile.fs.ensureDir(toArg);
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
let newRepo = new GitRepo(toArg);
done.resolve(newRepo);
return done.promise;
};
2016-11-22 20:49:40 +00:00
/**
* creates a new GitRepo instance after initializing a new Git Repository
*/
2019-06-18 13:17:50 +00:00
export const createRepoFromInit = async (destinationDirArg: string): Promise<GitRepo> => {
const done = q.defer<GitRepo>();
plugins.smartfile.fs.ensureDir(destinationDirArg);
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
let newRepo = new GitRepo(destinationDirArg);
done.resolve(newRepo);
return done.promise;
};