本文整理汇总了TypeScript中@angular-devkit/architect.BuilderContext.reportStatus方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BuilderContext.reportStatus方法的具体用法?TypeScript BuilderContext.reportStatus怎么用?TypeScript BuilderContext.reportStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/architect.BuilderContext
的用法示例。
在下文中一共展示了BuilderContext.reportStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: catchError
catchError(error => {
context.reportStatus('Error: ' + error);
return [{ success: false }];
}),
示例2: execute
async function execute(
options: ProtractorBuilderOptions,
context: BuilderContext,
): Promise<BuilderOutput> {
// ensure that only one of these options is used
if (options.devServerTarget && options.baseUrl) {
throw new Error(tags.stripIndents`
The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
`);
}
if (options.webdriverUpdate) {
try {
await updateWebdriver();
} catch (error) {
context.reportStatus('Error: ' + error);
return { success: false };
}
}
let baseUrl;
let server;
if (options.devServerTarget) {
const target = targetFromTargetString(options.devServerTarget);
const serverOptions = await context.getTargetOptions(target);
const overrides: Record<string, string | number | boolean> = { watch: false };
if (options.host !== undefined) { overrides.host = options.host; }
if (options.port !== undefined) { overrides.port = options.port; }
server = await context.scheduleTarget(target, overrides);
let result;
try {
result = await server.result;
} catch (error) {
context.reportStatus('Error: ' + error);
}
if (!result || !result.success) {
return { success: false };
}
if (typeof serverOptions.publicHost === 'string') {
let publicHost = serverOptions.publicHost as string;
if (!/^\w+:\/\//.test(publicHost)) {
publicHost = `${serverOptions.ssl
? 'https'
: 'http'}://${publicHost}`;
}
const clientUrl = url.parse(publicHost);
baseUrl = url.format(clientUrl);
} else if (typeof result.port === 'number') {
baseUrl = url.format({
protocol: serverOptions.ssl ? 'https' : 'http',
hostname: options.host,
port: result.port.toString(),
});
}
}
try {
return await runProtractor(context.workspaceRoot, { ...options, baseUrl });
} catch {
return { success: false };
} finally {
if (server) {
await server.stop();
}
}
}
示例3: _run
async function _run(
options: TslintBuilderOptions,
context: BuilderContext,
): Promise<BuilderOutput> {
const systemRoot = context.workspaceRoot;
process.chdir(context.currentDirectory);
const projectName = (context.target && context.target.project) || '<???>';
// Print formatter output only for non human-readable formats.
const printInfo =
['prose', 'verbose', 'stylish'].includes(options.format || '') && !options.silent;
context.reportStatus(`Linting ${JSON.stringify(projectName)}...`);
if (printInfo) {
context.logger.info(`Linting ${JSON.stringify(projectName)}...`);
}
if (!options.tsConfig && options.typeCheck) {
throw new Error('A "project" must be specified to enable type checking.');
}
const projectTslint = await _loadTslint();
const tslintConfigPath = options.tslintConfig
? path.resolve(systemRoot, options.tslintConfig)
: null;
const Linter = projectTslint.Linter;
let result: undefined | LintResult = undefined;
if (options.tsConfig) {
const tsConfigs = Array.isArray(options.tsConfig) ? options.tsConfig : [options.tsConfig];
context.reportProgress(0, tsConfigs.length);
const allPrograms = tsConfigs.map(tsConfig => {
return Linter.createProgram(path.resolve(systemRoot, tsConfig));
});
let i = 0;
for (const program of allPrograms) {
const partial = await _lint(
projectTslint,
systemRoot,
tslintConfigPath,
options,
program,
allPrograms,
);
if (result === undefined) {
result = partial;
} else {
result.failures = result.failures
.filter(curr => {
return !partial.failures.some(prev => curr.equals(prev));
})
.concat(partial.failures);
// we are not doing much with 'errorCount' and 'warningCount'
// apart from checking if they are greater than 0 thus no need to dedupe these.
result.errorCount += partial.errorCount;
result.warningCount += partial.warningCount;
result.fileNames = [...new Set([...result.fileNames, ...partial.fileNames])];
if (partial.fixes) {
result.fixes = result.fixes ? result.fixes.concat(partial.fixes) : partial.fixes;
}
}
context.reportProgress(++i, allPrograms.length);
}
} else {
result = await _lint(projectTslint, systemRoot, tslintConfigPath, options);
}
if (result == undefined) {
throw new Error('Invalid lint configuration. Nothing to lint.');
}
if (!options.silent) {
const Formatter = projectTslint.findFormatter(options.format || '');
if (!Formatter) {
throw new Error(`Invalid lint format "${options.format}".`);
}
const formatter = new Formatter();
const output = formatter.format(result.failures, result.fixes, result.fileNames);
if (output.trim()) {
context.logger.info(output);
}
}
if (result.warningCount > 0 && printInfo) {
context.logger.warn('Lint warnings found in the listed files.');
}
if (result.errorCount > 0 && printInfo) {
context.logger.error('Lint errors found in the listed files.');
}
if (result.warningCount === 0 && result.errorCount === 0 && printInfo) {
context.logger.info('All files pass linting.');
}
//.........这里部分代码省略.........