本文整理汇总了TypeScript中chalk.underline函数的典型用法代码示例。如果您正苦于以下问题:TypeScript underline函数的具体用法?TypeScript underline怎么用?TypeScript underline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了underline函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: printCommandHelp
function printCommandHelp(name: string, command: ICommandModule) {
if (!command) {
console.log(`Unrecognized command: ${chalk.bold.red.underline(name)}`)
printHelp()
return
}
console.log(`${chalk.gray('github')} ${command.command}`)
if (command.aliases) {
for (const alias of command.aliases) {
console.log(chalk.gray(`github ${alias}`))
}
}
console.log()
const [title, body] = command.description.split('\n', 1)
console.log(chalk.bold(title))
if (body) {
console.log(body)
}
const { options, args } = command
if (options) {
console.log(chalk.underline('\nOptions:'))
printTable(
Object.keys(options)
.map(k => [k, options[k]] as [string, IOption])
.map(([optionName, option]) => [
[optionName, ...(option.aliases || [])]
.map(dasherizeOption)
.map(x => chalk.bold.blue(x))
.join(chalk.gray(', ')),
option.description,
chalk.gray(`[${chalk.underline(option.type)}]`),
])
)
}
if (args && args.length) {
console.log(chalk.underline('\nArguments:'))
printTable(
args.map(arg => [
(arg.required ? chalk.bold : chalk).blue(arg.name),
arg.required ? chalk.gray('(required)') : '',
arg.description,
chalk.gray(`[${chalk.underline(arg.type)}]`),
])
)
}
}
示例2: createYargs
export function createYargs(): any {
return yargs
.version()
.option("osx", {
alias: "o",
describe: "Build for OS X",
type: "array",
})
.option("linux", {
alias: "l",
describe: "Build for Linux",
type: "array",
})
.option("win", {
alias: ["w", "windows"],
describe: "Build for Windows",
type: "array",
})
.option("x64", {
describe: "Build for x64",
type: "boolean",
})
.option("ia32", {
describe: "Build for ia32",
type: "boolean",
})
// .option("target", {
// alias: "t",
// describe: "Target package types",
// choices: commonTargets,
// })
.option("publish", {
alias: "p",
describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`,
choices: ["onTag", "onTagOrDraft", "always", "never"],
})
.option("platform", {
choices: ["osx", "win", "linux", "darwin", "win32", "all"],
})
.option("arch", {
choices: ["ia32", "x64", "all"],
})
.strict()
.help()
.epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`)
}
示例3:
.map(([optionName, option]) => [
[optionName, ...(option.aliases || [])]
.map(dasherizeOption)
.map(x => chalk.bold.blue(x))
.join(chalk.gray(', ')),
option.description,
chalk.gray(`[${chalk.underline(option.type)}]`),
])
示例4: widthOfString
results.forEach(function(result) {
const messages = result.messages;
if (messages.length === 0) {
return;
}
total += messages.length;
output += chalk.underline(result.filePath) + "\n";
output +=
table(
messages.map(function(message) {
let messageType;
// fixable
const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
if (message.fix) {
totalFixable++;
}
if ((message as any).fatal || message.severity === 2) {
messageType = fixableIcon + chalk.red("error");
summaryColor = "red";
errors++;
} else {
messageType = fixableIcon + chalk.yellow("warning");
warnings++;
}
return [
"",
message.line || 0,
message.column || 0,
messageType,
message.message.replace(/\.$/, ""),
chalk.gray(message.ruleId || "")
];
}),
{
align: ["", "r", "l"],
stringLength: function(str: string) {
const lines = chalk.stripColor(str).split("\n");
return Math.max.apply(
null,
lines.map(function(line: string) {
return widthOfString(line);
})
);
}
}
)
.split("\n")
.map(function(el: string) {
return el.replace(/(\d+)\s+(\d+)/, function(_, p1, p2) {
return chalk.gray(p1 + ":" + p2);
});
})
.join("\n") + "\n\n";
});
示例5: async
export default async () => {
// check if this folder contains an already bootstrapped project
// check if config.json exists
// validate config.json
// ask if config should be modified
// walk config tree and ask questions
console.log(' - now configuring đŠđżâđ');
if (
![
checkFile('package.json'),
checkFile('firebase.json'),
checkFile('firestore.rules'),
checkFile('firestore.indexes.json'),
checkFile('storage.rules'),
checkFile('.firebaserc'),
].every(Boolean)
) {
return;
}
try {
const projectId = await getProjectId();
const { apiKey } = await prompt<{ apiKey: string }>([
{
type: 'input',
name: 'apiKey',
message: `Visit this page ${chalk.underline(
`https://console.firebase.google.com/project/${projectId}/settings/general/`
)} and paste the variable ${chalk.italic('apiKey')} here:`,
},
]);
let overwriteEnv = true;
if (checkFile('.env', false)) {
overwriteEnv = (await prompt<{ overwriteEnv: boolean }>({
type: 'confirm',
name: 'overwriteEnv',
message: 'File .env already exists. Do you want to overwrite it?',
initial: false,
})).overwriteEnv;
}
if (overwriteEnv) {
writeEnvFile(projectId, apiKey);
}
// TODO: generate config.json
// TODO: upload cloud functions config
// TODO: run npm build to generate editor in public folder
console.log('Please enable Firestore in the Firebase console');
console.log('Then, run firebase deploy');
} catch (error) {
console.log(error);
}
};
示例6: toString
public toString(): string {
var count = " " + chalk.red(logSymbols.error) + " " +
this.count + " error" +
(this.ruleFailures.length > 1 ? "s" : "");
var output = "\n" + chalk.underline(this.fileName) + "\n" +
this.generateFailureStrings() +
"\n\n" + count + "\n\n";
if (this.options.bell) { output += "\x07"; }
return output;
}
示例7: printHelp
function printHelp() {
console.log(chalk.underline('Commands:'))
const table: string[][] = []
for (const commandName of Object.keys(commands)) {
const command = commands[commandName]
table.push([chalk.bold(command.command), command.description])
}
printTable(table)
console.log(
`\nRun ${chalk.bold(
`github help ${chalk.gray('<command>')}`
)} for details about each command`
)
}
示例8: widthOfString
results.forEach(function(result) {
if (!result.applyingMessages || !result.remainingMessages) {
return;
}
const messages = result.applyingMessages;
// still error count
const remainingMessages = result.remainingMessages;
errors += remainingMessages.length;
if (messages.length === 0) {
return;
}
output += `${chalk.underline(result.filePath)}\n`;
output += `${table(
messages.map(function(message) {
// fixable
totalFixed++;
const messageType = chalk[greenColor].bold("\u2714 ");
return [
"",
message.line || 0,
message.column || 0,
messageType,
message.message.replace(/\.$/, ""),
chalk.gray(message.ruleId || "")
];
}),
{
align: ["", "r", "l"],
stringLength: (str: string) => {
const lines = chalk.stripColor(str).split("\n");
return Math.max.apply(
null,
lines.map(function(line: string) {
return widthOfString(line);
})
);
}
}
)
.split("\n")
.map(function(el: string) {
return el.replace(/(\d+)\s+(\d+)/, function(_m, p1, p2) {
return chalk.gray(`${p1}:${p2}`);
});
})
.join("\n")}\n\n`;
});
示例9: clearConsole
multiCompiler.plugin('done', (stats: Stats) => {
if (isInteractive) {
clearConsole()
}
// We have switched off the default Webpack output in WebpackDevServer
// options so we are going to "massage" the warnings and errors and present
// them in a readable focused way.
const messages = formatWebpackMessages(stats.toJson())
const isSuccessful = !messages.errors.length && !messages.warnings.length
if (isSuccessful) {
building.succeed(`Compiled successfully!`)
}
// If errors exist, only show errors.
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1
}
building.fail(`Failed to compile`)
// tslint:disable-next-line:no-console
console.log(messages.errors.join('\n\n'))
return
}
// Show warnings if no errors were found.
if (messages.warnings.length) {
building.warn('Compiled with warnings')
// tslint:disable-next-line:no-console
console.log(messages.warnings.join('\n\n'))
// Teach some ESLint tricks.
// tslint:disable-next-line:no-console
console.log(
'\nSearch for the ' +
chalk.underline(chalk.yellow('keywords')) +
' to learn more about each warning.'
)
// tslint:disable-next-line:no-console
console.log(
'To ignore, add ' +
chalk.cyan('// eslint-disable-next-line') +
' to the line before.\n'
)
}
})
示例10:
export const result = (
label: string = 'TOTAL',
prettySizeBefore: string,
prettySizeAfter: string,
prettySizeSaving: string,
sizeSavingPercent: number,
qualityPercent: number
) => {
console.log(
'%s %s was: %s now: %s saving: %s (%s)',
color.green('â'),
chalk.underline(label),
color.red(prettySizeBefore),
color.green(prettySizeAfter),
color.green(prettySizeSaving),
color.green(`${sizeSavingPercent.toFixed(2)}%`)
);
};