Browse Source

now-deploy: don't check update

master
nkzawa 9 years ago
parent
commit
0bd3127687
  1. 29
      bin/now-deploy

29
bin/now-deploy

@ -5,7 +5,6 @@ import { resolve } from 'path';
import login from '../lib/login'; import login from '../lib/login';
import * as cfg from '../lib/cfg'; import * as cfg from '../lib/cfg';
import { version } from '../../package'; import { version } from '../../package';
import checkUpdate from '../lib/check-update';
import Logger from '../lib/build-logger'; import Logger from '../lib/build-logger';
import bytes from 'bytes'; import bytes from 'bytes';
import chalk from 'chalk'; import chalk from 'chalk';
@ -51,43 +50,35 @@ const force = argv.f || argv.force;
const forceSync = argv.F || argv.forceSync; const forceSync = argv.F || argv.forceSync;
const shouldLogin = argv.L || argv.login; const shouldLogin = argv.L || argv.login;
// auto-update checking
const config = cfg.read(); const config = cfg.read();
const update = checkUpdate({ debug });
const exit = (code) => {
update.then(() => process.exit(code));
// don't wait for updates more than a second
// when the process really wants to exit
setTimeout(() => process.exit(code), 1000);
};
if (argv.h || argv.help) { if (argv.h || argv.help) {
help(); help();
exit(0); process.exit(0);
} else if (argv.v || argv.version) { } else if (argv.v || argv.version) {
console.log(chalk.bold('𝚫 now'), version); console.log(chalk.bold('𝚫 now'), version);
exit(0); process.exit(0);
} else if (!config.token || shouldLogin) { } else if (!config.token || shouldLogin) {
login() login()
.then((token) => { .then((token) => {
if (shouldLogin) { if (shouldLogin) {
console.log('> Logged in successfully. Token saved in ~/.now.json'); console.log('> Logged in successfully. Token saved in ~/.now.json');
exit(0); process.exit(0);
} else { } else {
sync(token).catch((err) => { sync(token).catch((err) => {
error(`Unknown error: ${err.stack}`); error(`Unknown error: ${err.stack}`);
exit(1); process.exit(1);
}); });
} }
}) })
.catch((e) => { .catch((e) => {
error(`Authentication error – ${e.message}`); error(`Authentication error – ${e.message}`);
exit(1); process.exit(1);
}); });
} else { } else {
sync(config.token).catch((err) => { sync(config.token).catch((err) => {
error(`Unknown error: ${err.stack}`); error(`Unknown error: ${err.stack}`);
exit(1); process.exit(1);
}); });
} }
@ -154,7 +145,7 @@ async function sync (token) {
now.on('error', (err) => { now.on('error', (err) => {
error('Upload failed'); error('Upload failed');
handleError(err); handleError(err);
exit(1); process.exit(1);
}); });
} else { } else {
console.log('> Sync complete (cached)'); console.log('> Sync complete (cached)');
@ -172,11 +163,11 @@ function printLogs (host) {
const logger = new Logger(host); const logger = new Logger(host);
logger.on('error', () => { logger.on('error', () => {
console.log('> Connection error.'); console.log('> Connection error.');
exit(1); process.exit(1);
}); });
logger.on('close', () => { logger.on('close', () => {
console.log(`${chalk.cyan('> Deployment complete!')}`); console.log(`${chalk.cyan('> Deployment complete!')}`);
exit(0); process.exit(0);
}); });
} }
@ -198,7 +189,7 @@ function handleError (err) {
} else { } else {
error(`Unexpected error. Please try later. (${err.message})`); error(`Unexpected error. Please try later. (${err.message})`);
} }
exit(1); process.exit(1);
} }
function error (err) { function error (err) {

Loading…
Cancel
Save