Leo Lamprecht
8 years ago
No known key found for this signature in database
GPG Key ID: B08517883D5E0E10
1 changed files with
15 additions and
1 deletions
-
lib/github.js
|
|
@ -7,7 +7,8 @@ import download from 'download' |
|
|
|
import tmp from 'tmp-promise' |
|
|
|
|
|
|
|
const downloadRepo = async repoPath => { |
|
|
|
const url = `https://api.github.com/repos/${repoPath}/tarball` |
|
|
|
const pathParts = gitPathParts(repoPath) |
|
|
|
const url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}` |
|
|
|
|
|
|
|
const tmpDir = await tmp.dir({ |
|
|
|
// We'll remove it manually once deployment is done
|
|
|
@ -31,6 +32,19 @@ const downloadRepo = async repoPath => { |
|
|
|
return tmpDir |
|
|
|
} |
|
|
|
|
|
|
|
export const gitPathParts = main => { |
|
|
|
let ref = '' |
|
|
|
|
|
|
|
if (main.split('/')[1].includes('#')) { |
|
|
|
const parts = main.split('#') |
|
|
|
|
|
|
|
ref = parts[1] |
|
|
|
main = parts[0] |
|
|
|
} |
|
|
|
|
|
|
|
return {main, ref} |
|
|
|
} |
|
|
|
|
|
|
|
export const isRepoPath = path => { |
|
|
|
if (!path) { |
|
|
|
return false |
|
|
|