Browse Source

use now-io api v2 (#132)

master
Naoyuki Kanezawa 8 years ago
committed by Guillermo Rauch
parent
commit
463ea607ff
  1. 10
      lib/build-logger.js

10
lib/build-logger.js

@ -14,7 +14,7 @@ export default class Logger extends EventEmitter {
// readyState // readyState
this.building = false; this.building = false;
this.socket = io(`https://io.now.sh?host=${host}`); this.socket = io(`https://io.now.sh?host=${host}&v=2`);
this.socket.once('error', this.onSocketError.bind(this)); this.socket.once('error', this.onSocketError.bind(this));
this.socket.on('state', this.onState.bind(this)); this.socket.on('state', this.onState.bind(this));
this.socket.on('logs', this.onLog.bind(this)); this.socket.on('logs', this.onLog.bind(this));
@ -56,18 +56,20 @@ export default class Logger extends EventEmitter {
if (this.quiet) return; if (this.quiet) return;
const data = log.object ? JSON.stringify(log.object) : log.text;
if ('command' === log.type) { if ('command' === log.type) {
console.log(`${chalk.gray('>')}${log.data}`); console.log(`${chalk.gray('>')}${data}`);
this.lines.reset(); this.lines.reset();
} else if ('stderr' === log.type) { } else if ('stderr' === log.type) {
log.data.split('\n').forEach((v) => { data.split('\n').forEach((v) => {
if (v.length) { if (v.length) {
console.error(chalk.red(`> ${v}`)); console.error(chalk.red(`> ${v}`));
} }
}); });
this.lines.reset(); this.lines.reset();
} else if ('stdout' === log.type) { } else if ('stdout' === log.type) {
log.data.split('\n').forEach((v) => { data.split('\n').forEach((v) => {
if (v.length) { if (v.length) {
this.lines.write(`${chalk.gray('>')} ${v}`); this.lines.write(`${chalk.gray('>')} ${v}`);
} }

Loading…
Cancel
Save