Browse Source

Auth build logger (#425)

* sort build logs (#19)

* authenticate build logger
master
Naoyuki Kanezawa 8 years ago
committed by Matheus Fernandes
parent
commit
05ed90e2a2
  1. 2
      bin/now-deploy.js
  2. 11
      lib/build-logger.js

2
bin/now-deploy.js

@ -675,7 +675,7 @@ async function sync(token) {
function printLogs(host, token) {
// Log build
const logger = new Logger(host, { debug, quiet });
const logger = new Logger(host, token, { debug, quiet });
logger.on('error', async err => {
if (!quiet) {

11
lib/build-logger.js

@ -33,9 +33,10 @@ class Lines {
}
module.exports = class Logger extends EventEmitter {
constructor(host, { debug = false, quiet = false } = {}) {
constructor(host, token, { debug = false, quiet = false } = {}) {
super();
this.host = host;
this.token = token;
this.debug = debug;
this.quiet = quiet;
@ -44,6 +45,7 @@ module.exports = class Logger extends EventEmitter {
this.socket = io(`https://io.now.sh/states?host=${host}&v=2`);
this.socket.once('error', this.onSocketError.bind(this));
this.socket.on('auth', this.onAuth.bind(this));
this.socket.on('state', this.onState.bind(this));
this.socket.on('logs', this.onLog.bind(this));
this.socket.on('backend', this.onComplete.bind(this));
@ -54,6 +56,13 @@ module.exports = class Logger extends EventEmitter {
this.buf = [];
}
onAuth(callback) {
if (this.debug) {
console.log('> [debug] authenticate');
}
callback(this.token);
}
onState(state) {
// Console.log(state)
if (!state.id) {

Loading…
Cancel
Save