From 772b29704089354037232308fd0adaf6e8d06f19 Mon Sep 17 00:00:00 2001 From: develar Date: Sat, 29 Oct 2016 10:55:45 +0200 Subject: [PATCH] feat: use warning emoji instead of plain text --- package.json | 1 + src/util/log.ts | 5 ++++- typings/node-emoji.d.ts | 3 +++ yarn.lock | 28 +++++++++++++++++----------- 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 typings/node-emoji.d.ts diff --git a/package.json b/package.json index 5b5b3f8bcb9..a7b7cb09fd0 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "lodash.template": "^4.4.0", "mime": "^1.3.4", "minimatch": "^3.0.3", + "node-emoji": "^1.4.1", "normalize-package-data": "^2.3.5", "parse-color": "^1.0.0", "plist": "^2.0.1", diff --git a/src/util/log.ts b/src/util/log.ts index 34e8970db3b..49f1c684730 100644 --- a/src/util/log.ts +++ b/src/util/log.ts @@ -4,6 +4,7 @@ import BluebirdPromise from "bluebird-lst-c" import { eraseLines } from "ansi-escapes" import * as cursor from "cli-cursor" import prettyMs from "pretty-ms" +import { get as getEmoji } from "node-emoji" interface Line { // text must be \n terminated @@ -35,11 +36,13 @@ class Logger { private lines: Array = [] private logTime = process.env.LOG_TIME === "true" + private readonly isTTY = (process.stdout).isTTY + constructor(private stream: WritableStream) { } warn(message: string): void { - this.log(yellow(`Warning: ${message}`)) + this.log((this.isTTY ? (getEmoji("warning") + " ") : "Warning: ") + yellow(message)) } log(message: string): void { diff --git a/typings/node-emoji.d.ts b/typings/node-emoji.d.ts new file mode 100644 index 00000000000..ed3a412e4e7 --- /dev/null +++ b/typings/node-emoji.d.ts @@ -0,0 +1,3 @@ +declare module "node-emoji" { + function get(name: string): string +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 6e6e453d20e..4b1bbd0e5f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1,8 +1,8 @@ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. # yarn lockfile v1 "@develar/semantic-release@^6.3.21": - version "6.3.21" - resolved "https://registry.yarnpkg.com/@develar/semantic-release/-/semantic-release-6.3.21.tgz#600dcfc607ab7378546222748373b9c88fa05cb1" + version "6.3.23" + resolved "https://registry.yarnpkg.com/@develar/semantic-release/-/semantic-release-6.3.23.tgz#80c8ecd7369cf4a5c442d59d24bd614c051dd004" dependencies: "@semantic-release/commit-analyzer" "^2.0.0" "@semantic-release/error" "^1.0.0" @@ -2449,10 +2449,6 @@ jodid25519@^1.0.0: dependencies: jsbn "~0.1.0" -js-tokens@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-1.0.3.tgz#14e56eb68c8f1a92c43d59f5014ec29dc20f2ae1" - js-tokens@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" @@ -2705,10 +2701,10 @@ longest@^1.0.1: resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" loose-envify@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.2.0.tgz#69a65aad3de542cf4ee0f4fe74e8e33c709ccb0f" + version "1.3.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" dependencies: - js-tokens "^1.0.1" + js-tokens "^2.0.0" loud-rejection@^1.0.0, loud-rejection@^1.6.0: version "1.6.0" @@ -2886,6 +2882,12 @@ ncp@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3" +node-emoji@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.4.1.tgz#c9fa0cf91094335bcb967a6f42b2305c15af2ebc" + dependencies: + string.prototype.codepointat "^0.2.0" + node-pre-gyp@^0.6.29: version "0.6.31" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.31.tgz#d8a00ddaa301a940615dbcc8caad4024d58f6017" @@ -3775,6 +3777,10 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +string.prototype.codepointat@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78" + stringifier@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/stringifier/-/stringifier-1.3.0.tgz#def18342f6933db0f2dbfc9aa02175b448c17959" @@ -3987,8 +3993,8 @@ typedarray@~0.0.5: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" typescript@^2.1.0-dev.20161028: - version "2.1.0-dev.20161028" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.0-dev.20161028.tgz#4b7b67c734254db040566f7289f7eda5e9565825" + version "2.1.0-dev.20161029" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.0-dev.20161029.tgz#889598d3b2a3b5c8d7e2ad6a8ba7f300eff27caa" uc.micro@^1.0.1, uc.micro@^1.0.3: version "1.0.3"