Leo Lamprecht
8 years ago
No known key found for this signature in database
GPG Key ID: B08517883D5E0E10
2 changed files with
29 additions and
15 deletions
-
bin/now-deploy.js
-
lib/github.js
|
|
@ -195,6 +195,8 @@ async function sync(token) { |
|
|
|
const start = Date.now() |
|
|
|
const rawPath = argv._[0] |
|
|
|
|
|
|
|
let gitHubRepo |
|
|
|
|
|
|
|
const stopDeployment = msg => { |
|
|
|
error(msg) |
|
|
|
process.exit(1) |
|
|
@ -206,18 +208,21 @@ async function sync(token) { |
|
|
|
const repo = await onGitHub(rawPath, debug) |
|
|
|
|
|
|
|
if (repo) { |
|
|
|
path = repo |
|
|
|
path = repo.path |
|
|
|
gitHubRepo = repo |
|
|
|
} else if (isRepoPath(rawPath)) { |
|
|
|
stopDeployment(`This path neither exists, nor is there a repository named "${rawPath}" on GitHub`) |
|
|
|
} else { |
|
|
|
stopDeployment(`Could not read directory ${chalk.bold(path)}`) |
|
|
|
} |
|
|
|
|
|
|
|
console.log(repo) |
|
|
|
} |
|
|
|
|
|
|
|
if (!quiet) { |
|
|
|
console.log(`> Deploying ${chalk.bold(toHumanPath(path))}`) |
|
|
|
if (gitHubRepo) { |
|
|
|
console.log(`> Deploying GitHub repository "${chalk.bold(toHumanPath(rawPath))}"`) |
|
|
|
} else { |
|
|
|
console.log(`> Deploying ${chalk.bold(toHumanPath(path))}`) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
process.exit() |
|
|
|
|
|
@ -1,4 +1,8 @@ |
|
|
|
// Native
|
|
|
|
import path from 'path' |
|
|
|
|
|
|
|
// Packages
|
|
|
|
import fs from 'fs-promise' |
|
|
|
import fetch from 'node-fetch' |
|
|
|
import download from 'download' |
|
|
|
import tmp from 'tmp-promise' |
|
|
@ -29,17 +33,16 @@ const exists = async repoPath => { |
|
|
|
const downloadRepo = async repoPath => { |
|
|
|
const url = `https://api.github.com/repos/${repoPath}/tarball` |
|
|
|
|
|
|
|
const tmpDir = await tmp.dir({ |
|
|
|
let tmpDir = await tmp.dir({ |
|
|
|
keep: true |
|
|
|
}) |
|
|
|
|
|
|
|
try { |
|
|
|
await download(url, tmpDir.path, { |
|
|
|
extract: true |
|
|
|
}) |
|
|
|
} catch (err) { |
|
|
|
error(`Not able to download repo: ${err.stack}`) |
|
|
|
} |
|
|
|
await download(url, tmpDir.path, { |
|
|
|
extract: true |
|
|
|
}) |
|
|
|
|
|
|
|
const tmpContents = await fs.readdir(tmpDir.path) |
|
|
|
tmpDir.path = path.join(tmpDir.path, tmpContents[0]) |
|
|
|
|
|
|
|
return tmpDir |
|
|
|
} |
|
|
@ -75,8 +78,14 @@ export const onGitHub = async (path, debug) => { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
const tmpDir = await downloadRepo(path) |
|
|
|
console.log(tmpDir) |
|
|
|
let tmpDir |
|
|
|
|
|
|
|
return 'test' |
|
|
|
try { |
|
|
|
tmpDir = await downloadRepo(path) |
|
|
|
} catch (err) { |
|
|
|
error(`Not able to download repo: ${err.stack}`) |
|
|
|
process.exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
return tmpDir |
|
|
|
} |
|
|
|