smartgit/ts/index.ts

32 lines
910 B
TypeScript
Raw Normal View History

2016-11-22 20:49:40 +00:00
import * as q from 'q'
2016-03-30 23:59:45 +00:00
import plugins = require("./smartgit.plugins");
2016-11-22 20:49:40 +00:00
import { GitRepo } from './smartgit.classes.gitrepo'
export {
GitRepo
}
/**
* creates a new GitRepo Instance after cloning a project
*/
export let createRepoFromClone = (fromArg: string, toArg: string) => {
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
}
/**
* creates a new GitRepo instance after initializing a new Git Repository
*/
export let createRepoFromInit = (destinationDirArg: string) => {
let done = q.defer<GitRepo>()
plugins.smartfile.fs.ensureDir(destinationDirArg)
2016-11-22 21:22:24 +00:00
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
2016-11-22 20:49:40 +00:00
let newRepo = new GitRepo(destinationDirArg)
done.resolve(newRepo)
2016-11-22 21:22:24 +00:00
return done.promise
2016-11-22 20:49:40 +00:00
}