本文整理汇总了TypeScript中colors.gray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript gray函数的具体用法?TypeScript gray怎么用?TypeScript gray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gray函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addColor
function addColor (str: string) {
if (hasFlag('no-color')) {
return str
}
if (hasFlag('color')) {
return colors.gray(str)
}
if (supportsColor()) {
return colors.gray(str)
}
return str
}
示例2: constructor
constructor(options: {}, title: string, private controlToken: ProgressContolToken, private total?: number) {
super(options);
this.state = StreamState.preparing;
this.haveTotal = typeof this.total === 'number';
const progressWithTotal = rigthPad(2000, ` ${colors.green(title)} [{bar}] `
+ `${colors.gray('{_value} / {_total} Mb')} {percentage}% {duration_formatted}`);
const progressWithoutTotal = rigthPad(2000, ` ${colors.green(title)} ${colors.gray(' {_value} Mb')}` +
` {duration_formatted}`);
this.progress = new cliProgress.Bar({
format: this.haveTotal ? progressWithTotal : progressWithoutTotal,
barsize: 40,
etaBuffer: 50,
hideCursor: false,
clearOnComplete: true,
linewrap: false,
fps: 50,
});
this.completed = 0;
this.once('end', () => {
this.die();
});
this.on('pipe', () => {
if (this.state !== StreamState.bypass && this.state !== StreamState.visible) {
this.state = StreamState.connected;
}
});
this.on('unpipe', () => {
if (this.state !== StreamState.bypass) {
this.toggleVisibility(false);
this.state = StreamState.preparing;
}
});
this.controlToken.toggleVisibility = (shouldBeVisibe) => this.toggleVisibility(shouldBeVisibe);
this.controlToken.toggleBypass = (shouldBeVisibe) => this.toggleBypass(shouldBeVisibe);
this.controlToken.terminate = () => this.die();
}
示例3: Controllers
let controllers: Controllers = new Controllers(app);
controllers.init();
// setup ssl self hosting (use the same certs from browsersync)
let httpsOptions: https.ServerOptions = {
cert: fs.readFileSync(__dirname + '/../../node_modules/browser-sync/lib/server/certs/server.crt'),
key: fs.readFileSync(__dirname + '/../../node_modules/browser-sync/lib/server/certs/server.key')
};
let httpServerPort: number = process.env.PORT || 3433; // use server value (for Azure) or local port
// create & startup HTTPS webserver
https.createServer(httpsOptions, app)
.listen(httpServerPort);
console.log(colors.cyan('+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+'));
console.log(colors.green('Starting up https server...'));
console.log(colors.green('Available on:'));
// list IPs listening on
let networks: { [index: string]: os.NetworkInterfaceInfo[] } = os.networkInterfaces();
Object.keys(networks).forEach((device: string) => {
networks[device].forEach((details: os.NetworkInterfaceInfo) => {
if (details.family === 'IPv4') {
console.log(colors.yellow(' https://' + details.address + ':' + httpServerPort));
}
});
});
console.log(colors.gray('Hit CTRL-C to stop the server'));
console.log(colors.cyan('+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+'));
示例4: tip
tip (msg: string) {
this.msg(LogType.TIP, msg)
},
info (msg: string) {
this.msg(LogType.INFO, msg)
},
debug (msg: string) {
this.msg(LogType.DEBUG, msg)
},
msg (logType: LogType, msg: string | Error | Object | any[]) {
if (logType.level < config.log.level) {
return
}
let dateTime = config.log.time
? colors.gray(`[${getDateTime()}] `)
: ''
if (_.isError(msg)) {
msg = msg.message
} else if (_.isPlainObject(msg) || _.isArray(msg)) {
msg = JSON.stringify(msg)
}
if (this.cb) {
this.cb(msg, logType, dateTime)
} else {
let color = colors[logType.color]
msg = dateTime + color(`[${logType.desc}]`) + ' ' + msg
if (logType.level >= LogLevel.WARN) {
示例5:
console.log()
console.log(colors.green("Done!!"))
console.log()
if (pkg.repository.url.trim()) {
console.log(colors.cyan("Now run:"))
console.log(colors.cyan(" npm install -g semantic-release-cli"))
console.log(colors.cyan(" semantic-release setup"))
console.log()
console.log(
colors.cyan('Important! Answer NO to "Generate travis.yml" question')
)
console.log()
console.log(
colors.gray(
'Note: Make sure "repository.url" in your package.json is correct before'
)
)
} else {
console.log(
colors.red(
'First you need to set the "repository.url" property in package.json'
)
)
console.log(colors.cyan("Then run:"))
console.log(colors.cyan(" npm install -g semantic-release-cli"))
console.log(colors.cyan(" semantic-release setup"))
console.log()
console.log(
colors.cyan('Important! Answer NO to "Generate travis.yml" question')
)
示例6: verbose
export function verbose(category: string, str: string, ...args: Array<any>): void{
verboset(colors.gray(category+' ') + str, ...args);
}