Browse Source

Clean up tmp dir for repo in a better way

master
Leo Lamprecht 8 years ago
parent
commit
c92d4dfb37
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 9
      bin/now-deploy.js
  2. 5
      lib/github.js

9
bin/now-deploy.js

@ -229,8 +229,12 @@ async function sync(token) {
} }
if (repo) { if (repo) {
// Tell now which directory to deploy
path = repo.path path = repo.path
gitHubRepo = true
// Set global variable for deleting tmp dir later
// once the deployment has finished
gitHubRepo = repo
} else if (isRepoPath(rawPath)) { } else if (isRepoPath(rawPath)) {
stopDeployment(`This path neither exists, nor is there a repository named "${rawPath}" on GitHub`) stopDeployment(`This path neither exists, nor is there a repository named "${rawPath}" on GitHub`)
} else { } else {
@ -529,7 +533,8 @@ function printLogs(host) {
} }
if (gitHubRepo) { if (gitHubRepo) {
fs.removeSync(path) // Delete temporary directory that contains repository
gitHubRepo.cleanup()
if (debug) { if (debug) {
console.log(`> [debug] Removed temporary repo directory`) console.log(`> [debug] Removed temporary repo directory`)

5
lib/github.js

@ -35,7 +35,10 @@ 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({ const tmpDir = await tmp.dir({
keep: true // We'll remove it manually once deployment is done
keep: true,
// Recursively remove directory when calling respective method
unsafeCleanup: true
}) })
await download(url, tmpDir.path, { await download(url, tmpDir.path, {

Loading…
Cancel
Save