Browse Source

now-deploy: stay quiet on non-tty

master
Guillermo Rauch 9 years ago
parent
commit
de932b8643
  1. 29
      bin/now-deploy

29
bin/now-deploy

@ -130,6 +130,8 @@ if (argv.h || argv.help) {
}); });
} }
const isTTY = process.stdout.isTTY;
async function sync (token) { async function sync (token) {
const start = Date.now(); const start = Date.now();
@ -138,7 +140,11 @@ async function sync (token) {
const now = new Now(apiUrl, token, { debug }); const now = new Now(apiUrl, token, { debug });
try { try {
await now.create(path, { forceNew: force, forceSync: forceSync }); await now.create(path, {
forceNew: force,
forceSync: forceSync,
quiet: !isTTY
});
} catch (err) { } catch (err) {
handleError(err); handleError(err);
process.exit(1); process.exit(1);
@ -147,15 +153,19 @@ async function sync (token) {
const { url } = now; const { url } = now;
const elapsed = ms(new Date() - start); const elapsed = ms(new Date() - start);
if (clipboard) { if (isTTY) {
try { if (clipboard) {
await copy(url); try {
console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} (copied to clipboard) [${elapsed}]`); await copy(url);
} catch (err) { console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} (copied to clipboard) [${elapsed}]`);
console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} [${elapsed}]`); } catch (err) {
console.log(`${chalk.cyan('> Ready!')} ${chalk.bold(url)} [${elapsed}]`);
}
} else {
console.log(`> ${url} [${elapsed}]`);
} }
} else { } else {
console.log(`> ${url} [${elapsed}]`); system.stdout.write(url);
} }
const start_u = new Date(); const start_u = new Date();
@ -209,9 +219,8 @@ async function sync (token) {
function printLogs (host) { function printLogs (host) {
// log build // log build
const logger = new Logger(host); const logger = new Logger(host, { debug, quiet: !isTTY });
logger.on('error', () => { logger.on('error', () => {
console.log('> Connection error.');
process.exit(1); process.exit(1);
}); });
logger.on('close', () => { logger.on('close', () => {

Loading…
Cancel
Save