mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 23:11:41 +00:00
Minor CLI and README cleanup
This commit is contained in:
50
cli/util/colors.d.ts
vendored
Normal file
50
cli/util/colors.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
interface Colors {
|
||||
/** Whether terminal colors are supported. */
|
||||
supported: boolean;
|
||||
/** Colors a string in gray if {@link supported}. */
|
||||
gray(text: string): string;
|
||||
/** Colors a string in red if {@link supported}. */
|
||||
red(text: string): string;
|
||||
/** Colors a string in green if {@link supported}. */
|
||||
green(text: string): string;
|
||||
/** Colors a string in yellow if {@link supported}. */
|
||||
yellow(text: string): string;
|
||||
/** Colors a string in blue if {@link supported}. */
|
||||
blue(text: string): string;
|
||||
/** Colors a string in magenta if {@link supported}. */
|
||||
magenta(text: string): string;
|
||||
/** Colors a string in cyan if {@link supported}. */
|
||||
cyan(text: string): string;
|
||||
/** Colors a string in white if {@link supported}. */
|
||||
white(text: string): string;
|
||||
}
|
||||
|
||||
interface Exports extends Colors {
|
||||
/** Standard output wrapper. */
|
||||
stdout: Colors;
|
||||
/** Standard error wrapper. */
|
||||
stderr: Colors;
|
||||
/** Creates an instance for the specified stream. */
|
||||
from(stream: any, base?: {}): Colors;
|
||||
/** Gray color escape sequence. */
|
||||
GRAY: string;
|
||||
/** Red color escape sequence. */
|
||||
RED: string;
|
||||
/** Green color escape sequence. */
|
||||
GREEN: string;
|
||||
/** Yellow color escape sequence. */
|
||||
YELLOW: string;
|
||||
/** Blue color escape sequence. */
|
||||
BLUE: string;
|
||||
/** Magenta color escape sequence. */
|
||||
MAGENTA: string;
|
||||
/** Cyan color escape sequence. */
|
||||
CYAN: string;
|
||||
/** White color escape sequence. */
|
||||
WHITE: string;
|
||||
/** Reset color escape sequence. */
|
||||
RESET: string;
|
||||
}
|
||||
|
||||
declare const colors: Exports;
|
||||
export = colors;
|
@ -1,39 +1,30 @@
|
||||
var hasColor = typeof process !== "undefined" && process && process.stdout && !!process.stdout.isTTY
|
||||
|| typeof env !== "undefined" && env && "TRAVIS" in env;
|
||||
var proc = typeof process !== "undefined" && process || {};
|
||||
var isCI = proc.env && "CI" in proc.env;
|
||||
|
||||
function from(stream, base) {
|
||||
var colors = base || {};
|
||||
colors.supported = (stream && !!stream.isTTY) || isCI;
|
||||
colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;
|
||||
colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;
|
||||
colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;
|
||||
colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;
|
||||
colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;
|
||||
colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;
|
||||
colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;
|
||||
colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;
|
||||
return colors;
|
||||
}
|
||||
|
||||
exports.stdout = from(proc.stdout, exports);
|
||||
exports.stderr = from(proc.stderr);
|
||||
exports.from = from;
|
||||
|
||||
exports.GRAY = "\u001b[90m";
|
||||
exports.RED = "\u001b[91m";
|
||||
exports.red = function(text) {
|
||||
return hasColor ? exports.RED + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.GREEN = "\u001b[92m";
|
||||
exports.green = function(text) {
|
||||
return hasColor ? exports.GREEN + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.YELLOW = "\u001b[93m";
|
||||
exports.yellow = function(text) {
|
||||
return hasColor ? exports.YELLOW + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.BLUE = "\u001b[94m";
|
||||
exports.blue = function(text) {
|
||||
return hasColor ? exports.BLUE + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.MAGENTA = "\u001b[95m";
|
||||
exports.magenta = function(text) {
|
||||
return hasColor ? exports.MAGENTA + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.CYAN = "\u001b[96m";
|
||||
exports.cyan = function(text) {
|
||||
return hasColor ? exports.CYAN + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.WHITE = "\u001b[97m";
|
||||
exports.white = function(text) {
|
||||
return hasColor ? exports.WHITE + text + exports.RESET : text;
|
||||
};
|
||||
|
||||
exports.RESET = "\u001b[0m";
|
||||
|
Reference in New Issue
Block a user