diff --git a/download/placeholder.js b/download/placeholder.js deleted file mode 100755 index 893b004..0000000 --- a/download/placeholder.js +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable no-var */ - -// Native -var path = require('path') -var fs = require('fs') - -var now = path.join(__dirname, 'dist', 'now') - -fs.writeFileSync( - now, - '#!/usr/bin/env node\n' + - 'console.log("\'Now\' binary downloading was interrupted. Please reinstall!")\n' -) diff --git a/download/src/index.js b/download/src/index.js index e9232b1..16a7fc3 100644 --- a/download/src/index.js +++ b/download/src/index.js @@ -1,8 +1,11 @@ +/* eslint-disable unicorn/no-process-exit */ + // Native import fs from 'fs' import path from 'path' // Packages +import onDeath from 'death' import fetch from 'node-fetch' // Utilities @@ -24,6 +27,22 @@ const platformToName = { } async function main() { + fs.writeFileSync( + now, + '#!/usr/bin/env node\n' + + 'console.log("Please wait until \'now\' installation completes!")\n' + ) + + onDeath(() => { + fs.writeFileSync( + now, + '#!/usr/bin/env node\n' + + 'console.log("The \'now\' installation did not complete successfully.")\n' + + 'console.log("Please run \'npm i -g now\' to reinstall!")\n' + ) + process.exit(); + }) + info('Retrieving the latest CLI version...') const downloadURL = `https://api.github.com/repos/zeit/now-cli/releases/tags/${packageJSON.version}` @@ -94,7 +113,5 @@ async function main() { main().catch(err => { console.error(err) - - // eslint-disable-next-line unicorn/no-process-exit process.exit(2) }) diff --git a/package.json b/package.json index 407aa8e..48958f7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "postinstall": "node download/postinstall.js", "precommit": "xo --quiet && lint-staged", - "prepublish": "in-install || (npm run webpack && node download/placeholder.js)", + "prepublish": "in-install || (npm run webpack && cp /dev/null download/dist/now)", "lint": "xo --quiet", "test": "npm run lint && ava", "pack": "pkg bin/now.js -c package.json -o packed/now", @@ -70,6 +70,7 @@ "credit-card": "3.0.1", "cross-spawn": "5.1.0", "dateformat": "2.0.0", + "death": "1.1.0", "docker-file-parser": "1.0.2", "dotenv": "4.0.0", "download": "6.1.0",