|
@ -1,4 +1,8 @@ |
|
|
|
|
|
// Native
|
|
|
|
|
|
import path from 'path' |
|
|
|
|
|
|
|
|
// Packages
|
|
|
// Packages
|
|
|
|
|
|
import fs from 'fs-promise' |
|
|
import fetch from 'node-fetch' |
|
|
import fetch from 'node-fetch' |
|
|
import download from 'download' |
|
|
import download from 'download' |
|
|
import tmp from 'tmp-promise' |
|
|
import tmp from 'tmp-promise' |
|
@ -29,17 +33,16 @@ const exists = async repoPath => { |
|
|
const downloadRepo = async repoPath => { |
|
|
const downloadRepo = async repoPath => { |
|
|
const url = `https://api.github.com/repos/${repoPath}/tarball` |
|
|
const url = `https://api.github.com/repos/${repoPath}/tarball` |
|
|
|
|
|
|
|
|
const tmpDir = await tmp.dir({ |
|
|
let tmpDir = await tmp.dir({ |
|
|
keep: true |
|
|
keep: true |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
try { |
|
|
await download(url, tmpDir.path, { |
|
|
await download(url, tmpDir.path, { |
|
|
extract: true |
|
|
extract: true |
|
|
}) |
|
|
}) |
|
|
|
|
|
} catch (err) { |
|
|
const tmpContents = await fs.readdir(tmpDir.path) |
|
|
error(`Not able to download repo: ${err.stack}`) |
|
|
tmpDir.path = path.join(tmpDir.path, tmpContents[0]) |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return tmpDir |
|
|
return tmpDir |
|
|
} |
|
|
} |
|
@ -75,8 +78,14 @@ export const onGitHub = async (path, debug) => { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const tmpDir = await downloadRepo(path) |
|
|
let tmpDir |
|
|
console.log(tmpDir) |
|
|
|
|
|
|
|
|
|
|
|
return 'test' |
|
|
try { |
|
|
|
|
|
tmpDir = await downloadRepo(path) |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
error(`Not able to download repo: ${err.stack}`) |
|
|
|
|
|
process.exit(1) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return tmpDir |
|
|
} |
|
|
} |
|
|