本文整理汇总了TypeScript中util.format函数的典型用法代码示例。如果您正苦于以下问题:TypeScript format函数的具体用法?TypeScript format怎么用?TypeScript format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getDockerConfig
public getDockerConfig(): string {
var authenticationToken = new Buffer(this.username+":"+this.password).toString('base64')
console.log("##vso[task.setvariable variable=CONTAINER_AUTHENTICATIONTOKEN;issecret=true;]" + authenticationToken);
var auths = util.format('{"auths": { "%s": {"auth": "%s", "email": "%s" } }, "HttpHeaders":{"X-Meta-Source-Client":"%s"} }', this.registry, authenticationToken,this.email, this.xMetaSourceClient);
return auths;
}
示例2: warn
warn(firstArg: any, ...rest: Array<any>) {
this._log('warn', format(firstArg, ...rest));
}
示例3: executePythonTool
var workingDirectory = tl.getInput('wd', true);
var serviceEndpointId = tl.getInput('serviceEndpoint', true);
var wheel: boolean = tl.getBoolInput('wheel');
var homedir = os.homedir();
var pypircFilePath = path.join(homedir, ".pypirc");
var pythonToolPath = tl.which('python', true);
var error = '';
//Generic service endpoint
var pythonServer = tl.getEndpointUrl(serviceEndpointId, false);
var username = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'username', false);
var password = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'password', false);
//Create .pypirc file
var text = util.format("[distutils] \nindex-servers =\n pypi \n[pypi] \nrepository=%s \nusername=%s \npassword=%s", pythonServer, username, password);
tl.writeFile(pypircFilePath, text, 'utf8');
(async () => {
//PyPI upload
try{
tl.cd(workingDirectory);
await executePythonTool("-m pip install twine --user");
await executePythonTool("setup.py sdist");
if(wheel){
await executePythonTool("-m pip install wheel --user");
await executePythonTool("setup.py bdist_wheel --universal");
}
await executePythonTool("-m twine upload dist/*");
}
catch(err){
示例4: onRunComplete
onRunComplete(contexts: Set<Context>, result: AggregatedResult): void {
const success =
result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0;
const firstContext = contexts.values().next();
const hasteFS =
firstContext && firstContext.value && firstContext.value.hasteFS;
let packageName;
if (hasteFS != null) {
// assuming root package.json is the first one
const [filePath] = hasteFS.matchFiles('package.json');
packageName =
filePath != null
? hasteFS.getModuleName(filePath)
: this._globalConfig.rootDir;
} else {
packageName = this._globalConfig.rootDir;
}
packageName = packageName != null ? `${packageName} - ` : '';
const notifyMode = this._globalConfig.notifyMode;
const statusChanged =
this._context.previousSuccess !== success || this._context.firstRun;
const testsHaveRun = result.numTotalTests !== 0;
if (
testsHaveRun &&
success &&
(notifyMode === 'always' ||
notifyMode === 'success' ||
notifyMode === 'success-change' ||
(notifyMode === 'change' && statusChanged) ||
(notifyMode === 'failure-change' && statusChanged))
) {
const title = util.format('%s%d%% Passed', packageName, 100);
const message = util.format(
(isDarwin ? '\u2705 ' : '') + '%d tests passed',
result.numPassedTests,
);
notifier.notify({icon, message, title});
} else if (
testsHaveRun &&
!success &&
(notifyMode === 'always' ||
notifyMode === 'failure' ||
notifyMode === 'failure-change' ||
(notifyMode === 'change' && statusChanged) ||
(notifyMode === 'success-change' && statusChanged))
) {
const failed = result.numFailedTests / result.numTotalTests;
const title = util.format(
'%s%d%% Failed',
packageName,
Math.ceil(Number.isNaN(failed) ? 0 : failed * 100),
);
const message = util.format(
(isDarwin ? '\u26D4\uFE0F ' : '') + '%d of %d tests failed',
result.numFailedTests,
result.numTotalTests,
);
const watchMode = this._globalConfig.watch || this._globalConfig.watchAll;
const restartAnswer = 'Run again';
const quitAnswer = 'Exit tests';
if (!watchMode) {
notifier.notify({
icon,
message,
title,
});
} else {
notifier.notify(
{
actions: [restartAnswer, quitAnswer],
closeLabel: 'Close',
icon,
message,
title,
},
(err, _, metadata) => {
if (err || !metadata) {
return;
}
if (metadata.activationValue === quitAnswer) {
exit(0);
return;
}
if (metadata.activationValue === restartAnswer) {
this._startRun(this._globalConfig);
}
},
);
}
//.........这里部分代码省略.........
示例5: print_stat
function print_stat() {
t2 = Date.now();
const str = util.format("R= %d W= %d T=%d t= %d",
client.bytesRead, client.bytesWritten, client.transactionsPerformed, (t2 - t1));
console.log(chalk.yellow.bold(str));
}
示例6: TOO_COMPLEX
export function TOO_COMPLEX() {
let fmt = `Method table is too complex. Try reducing the number of predicates or their degree of overlap.`;
return error(format(fmt));
}
示例7: DUPLICATE_PREDICATE
export function DUPLICATE_PREDICATE(normalised: string, predicates: string) {
let fmt = `The predicate '%s' is duplicated across multiple methods: %s. To resolve this, use a method chain.`;
return error(format(fmt, normalised, predicates));
}
示例8: INVALID_ARITY_OPTION
export function INVALID_ARITY_OPTION(value: any) {
let fmt = `Expected a positive integer or undefined value for options.arity, but found %j.`;
return error(format(fmt, value));
}
示例9: INVALID_NAME_OPTION
export function INVALID_NAME_OPTION(value: any) {
let fmt = `Expected a valid identifier or undefined value for options.name, but found %j.`;
return error(format(fmt, value));
}
示例10: constructor
constructor(private $dynamicHelpService: IDynamicHelpService,
private $injector: IInjector) {
// Injector's dynamicCallRegex doesn't have 'g' option, which we need here.
// Use ( ) in order to use $1 to get whole expression later
this.dynamicCallRegex = new RegExp(util.format("(%s)", this.$injector.dynamicCallRegex.source), "g");
}
示例11: test
test('works', async (t) => {
const url = format('http://unix:%s:%s', socketPath, '/');
t.is((await got(url)).body, 'ok');
});
示例12: delete
delete(id, callback) {
var path = format('/v1.0/inbox/messages/%s', id);
this.client.requesthandler.request('DELETE', path, null, null, 200, callback);
};
示例13: update
update(options: InboxUpdateOptions, callback: (err: any) => void) {
var path = format('/v1.0/inbox/messages/%s', options.id);
var query = { action: options.read ? 'read' : 'unread' };
this.client.requesthandler.request('PUT', path, query, null, 200, callback);
}
示例14: CliImport
export default function CliImport() {
let err;
let program = require('commander');
let colors = require('colors');
let pkg = require('../package.json');
let util = require('util');
program.version(pkg.version)
.option('-c, --collection <collection>', 'The Power BI workspace collection')
.option('-w, --workspace <workspaceId>', 'The Power BI workspace')
.option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
.option('-n, --displayName <displayName>', 'The dataset display name')
.option('-f, --file <file>', 'The PBIX file to upload')
.option('-o, --overwrite [overwrite]', 'Whether to overwrite a dataset with the same name. Default is false')
.option('-b --baseUri [baseUri]', 'The base uri to connect to');
program.on('--help', function () {
console.log(' Examples:');
console.log('');
console.log(' $ powerbi import -c <collection> -k <accessKey> -w <workspace> -f <file>');
});
program.parse(process.argv);
let settings = config.merge(program);
if (process.argv.length === 2) {
program.help();
} else {
try {
let options: powerbi.ImportFileOptions = {};
let token = powerbi.PowerBIToken.createDevToken(settings.collection, settings.workspace);
let credentials = new msrest.TokenCredentials(token.generate(settings.accessKey), 'AppToken');
let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);
if (!_.isUndefined(settings.overwrite) && settings.overwrite) {
options.nameConflict = 'Overwrite';
}
options.datasetDisplayName = settings.displayName;
if (!fs.existsSync(settings.file)) {
throw new Error(util.format('File "%s" not found', settings.file));
}
cli.print('Importing %s to workspace: %s', settings.file, settings.workspace);
client.imports.uploadFile(settings.collection, settings.workspace, settings.file, options, (err, result, request, response) => {
if (err) {
return cli.error(err);
}
let importResult: powerbi.ImportModel = result;
cli.print('File uploaded successfully');
cli.print('Import ID: %s', importResult.id);
checkImportState(client, importResult, (importStateErr, importStateResult) => {
if (importStateErr) {
return cli.print(importStateErr);
}
cli.print('Import succeeded');
});
});
} catch (err) {
cli.error(err);
}
}
/**
* Checks the import state of the requested import id
*/
function checkImportState(client: powerbi.PowerBIClient, importResult: powerbi.ImportModel, callback) {
client.imports.getImportById(settings.collection, settings.workspace, importResult.id, (err, result) => {
importResult = result;
cli.print('Checking import state: %s', importResult.importState);
if (importResult.importState === 'Succeeded' || importResult.importState === 'Failed') {
callback(null, importResult);
} else {
setTimeout(() => {
checkImportState(client, importResult, callback);
}, 500);
}
});
}
}
示例15: PREDICATE_SYNTAX
export function PREDICATE_SYNTAX(message: string) {
let fmt = `Predicate syntax error: %s`;
return error(format(fmt, message));
}