added some tests
This commit is contained in:
@ -24,7 +24,8 @@ export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
||||
plugins.shelljs.exec(`cd destinationDirArg && git init`)
|
||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
|
||||
let newRepo = new GitRepo(destinationDirArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
@ -8,17 +8,16 @@ export class GitRepo {
|
||||
repoBase: string
|
||||
constructor(repoBaseArg: string) {
|
||||
this.repoBase = repoBaseArg
|
||||
if (!this.check()) {
|
||||
throw new Error('no valid git repo')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean {
|
||||
try {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,10 +57,10 @@ export class GitRepo {
|
||||
/**
|
||||
* list remotes for a Gip
|
||||
*/
|
||||
remoteList(dirPathArg) {
|
||||
remoteList() {
|
||||
let done = q.defer()
|
||||
let remotes = {}
|
||||
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`)
|
||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote -v`)
|
||||
done.resolve(remotes)
|
||||
return done.promise
|
||||
};
|
||||
|
Reference in New Issue
Block a user