From 8c6cb53dcb9cf52ae368350b002044a2aad32d4a Mon Sep 17 00:00:00 2001 From: Stanislav Kljuhhin Date: Sun, 13 Nov 2016 16:29:10 +0100 Subject: [PATCH] Use chalk instead of hardcoded ANSI codes Improves the readability of the source code and prevents the raw ANSI codes from appearing in the log, if ran as a systemd service. --- lib/server.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index ca0659b..8712d83 100644 --- a/lib/server.js +++ b/lib/server.js @@ -16,6 +16,7 @@ var BridgeSetupManager = require("./bridgeSetupManager").BridgeSetupManager; var log = require("./logger")._system; var Logger = require('./logger').Logger; var mac = require("./util/mac"); +var chalk = require('chalk'); 'use strict'; @@ -578,9 +579,9 @@ Server.prototype._handleNewConfig = function(type, name, replace, config) { // Returns the setup code in a scannable format. Server.prototype._printPin = function(pin) { console.log("Scan this code with your HomeKit App on your iOS device to pair with Homebridge:"); - console.log("\x1b[30;47m%s\x1b[0m", " "); - console.log("\x1b[30;47m%s\x1b[0m", " ┌────────────┐ "); - console.log("\x1b[30;47m%s\x1b[0m", " │ " + pin + " │ "); - console.log("\x1b[30;47m%s\x1b[0m", " └────────────┘ "); - console.log("\x1b[30;47m%s\x1b[0m", " "); + console.log(chalk.black.bgWhite(" ")); + console.log(chalk.black.bgWhite(" ┌────────────┐ ")); + console.log(chalk.black.bgWhite(" │ " + pin + " │ ")); + console.log(chalk.black.bgWhite(" └────────────┘ ")); + console.log(chalk.black.bgWhite(" ")); }