diff --git a/bin/now-deploy.js b/bin/now-deploy.js index feb4a57..86f3d3b 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -229,8 +229,12 @@ async function sync(token) { } if (repo) { + // Tell now which directory to deploy path = repo.path - gitHubRepo = true + + // Set global variable for deleting tmp dir later + // once the deployment has finished + gitHubRepo = repo } else if (isRepoPath(rawPath)) { stopDeployment(`This path neither exists, nor is there a repository named "${rawPath}" on GitHub`) } else { @@ -529,7 +533,8 @@ function printLogs(host) { } if (gitHubRepo) { - fs.removeSync(path) + // Delete temporary directory that contains repository + gitHubRepo.cleanup() if (debug) { console.log(`> [debug] Removed temporary repo directory`) diff --git a/lib/github.js b/lib/github.js index 780c0a6..c8db1fb 100644 --- a/lib/github.js +++ b/lib/github.js @@ -35,7 +35,10 @@ const downloadRepo = async repoPath => { const url = `https://api.github.com/repos/${repoPath}/tarball` 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, {