本文整理汇总了TypeScript中Process.exit函数的典型用法代码示例。如果您正苦于以下问题:TypeScript exit函数的具体用法?TypeScript exit怎么用?TypeScript exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exit函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
export async function main() {
try {
let action = process.argv[2];
if (action == null)
action = "help";
console.log(action);
let func = actions[action] || exports[action] as Function;
await func();
process.exit(0);
}
catch (err) {
console.log(err);
process.exit(1);
}
}
示例2: catch
worker.on('message', (message: Message) => {
// set result from worker
result.set(worker.pid, {
diagnostics: message.diagnostics.map(NormalizedMessage.createFromJSON),
lints: message.lints.map(NormalizedMessage.createFromJSON)
});
// if we have result from all workers, send merged
if (result.hasAll()) {
const merged: Message = result.reduce(
(innerMerged: Message, innerResult: Message) => ({
diagnostics: innerMerged.diagnostics.concat(innerResult.diagnostics),
lints: innerMerged.lints.concat(innerResult.lints)
}),
{ diagnostics: [], lints: [] }
);
merged.diagnostics = NormalizedMessage.deduplicate(merged.diagnostics);
merged.lints = NormalizedMessage.deduplicate(merged.lints);
try {
process.send(merged);
} catch (e) {
// channel closed...
process.exit();
}
}
});
示例3: run
function run(cancellationToken: CancellationToken) {
let diagnostics: NormalizedMessage[] = [];
let lints: NormalizedMessage[] = [];
checker.nextIteration();
try {
diagnostics = checker.getDiagnostics(cancellationToken);
if (checker.hasLinter()) {
lints = checker.getLints(cancellationToken);
}
} catch (error) {
if (error instanceof ts.OperationCanceledException) {
return;
}
throw error;
}
if (!cancellationToken.isCancellationRequested()) {
try {
process.send({
diagnostics,
lints
});
} catch (e) {
// channel closed...
process.exit();
}
}
}
示例4: exit
.catch(exception => {
const message = options.debug
? chalk.red(exception.stack)
: chalk.red(exception.message) + ' (use --debug to see a full stack trace)';
log.error(`Failed to render application: ${message}`);
exit(1);
});
示例5: test
async function test() {
let pong = await db.ping();
console.log(pong);
pong = await db.ping();
console.log(pong);
pong = await db.ping();
console.log(pong);
pong = await db.ping();
console.log(pong);
process.exit()
}
示例6: exit
app.use((req, res, next) => {
console.log(req.url);
if (req.url === '/robots.txt') {
return;
}
if (req.url === '/integration/favicon.ico') {
return;
}
if (req.url === '/test/exit') {
res.send('exit');
exit(0);
return;
}
next();
});
示例7:
() => {
if (unknownCountriesMap.length) {
console.info(`\nOne or more Wiki pages has an unrecognised visa status. This could be due to
* A typo in the Wiki page
* A new visa status term not expected by the Wiki parser (Refer: https://github.com/vinaygopinath/visa-req-wiki-scraper/blob/master/utils/wiki.ts#L15
* A newly introduced visa status`);
unknownCountriesMap.forEach((it) => {
console.error(`\n${it.parentCountry} wiki page`);
it.unknownCountries.forEach((itt) => {
console.error(`Name: ${itt.name}\tVisa: ${itt.visa || 'N/A'}\tNote: ${itt.note || 'N/A'}`);
});
});
console.error('\nWiki scraper failed');
process.exit(1);
} else {
console.info('\nAll Wiki pages processed successfully');
}
}
示例8:
process.on('SIGINT', () => {
process.exit();
});
示例9: readFile
(async () => {
let countries: CountryInput[] | null = null;
try {
const countriesStr = await readFile('./input/countries.json', 'utf8');
countries = JSON.parse(countriesStr);
} catch (ex) {
console.error('Could not load list of countries. Check if countries.json exists and ensure that it is valid JSON');
}
if (!countries) {
process.exit(1);
}
const unknownCountriesMap: { parentCountry: string, unknownCountries: CountryOutput[] }[] = [];
BluebirdPromise.map(countries as CountryInput[], async (country: CountryInput) => {
const countryData = await WikiUtil.scrapeCountryData(country.demonym);
console.info(`\n\n****\nVisa requirements for ${country.demonym} citizens`);
const wikiUrl = `http://en.wikipedia.org/wiki/Visa_requirements_for_${WikiUtil.capitalize(country.demonym)}_citizens`;
console.info(`Wiki URL = ${wikiUrl}`);
console.info(`\n${country.name} stats:\n`);
let total = 0;
for (const visaReq in VisaRequirement) { // tslint:disable-line
const countryOutput: CountryOutput[] = countryData[WikiUtil.camelCaseVisaRequirement(VisaRequirement[visaReq])];
console.info(`${visaReq}: ${countryOutput.length}`);
total += countryOutput.length;
if (VisaRequirement[visaReq] === VisaRequirement.UNKNOWN && countryOutput.length) {
unknownCountriesMap.push({ parentCountry: country.name, unknownCountries: countryOutput });
}
}
console.info(`TOTAL: ${total}`);
countryData[WikiUtil.camelCaseVisaRequirement(VisaRequirement.NOT_REQUIRED)].push(new CountryOutput(country.name, null, 'home'));
return FileUtil.writeToFile(country.name, countryData);
}, { concurrency: CONCURRENT_SCRAPE_INSTANCES })
.then(
() => {
if (unknownCountriesMap.length) {
console.info(`\nOne or more Wiki pages has an unrecognised visa status. This could be due to
* A typo in the Wiki page
* A new visa status term not expected by the Wiki parser (Refer: https://github.com/vinaygopinath/visa-req-wiki-scraper/blob/master/utils/wiki.ts#L15
* A newly introduced visa status`);
unknownCountriesMap.forEach((it) => {
console.error(`\n${it.parentCountry} wiki page`);
it.unknownCountries.forEach((itt) => {
console.error(`Name: ${itt.name}\tVisa: ${itt.visa || 'N/A'}\tNote: ${itt.note || 'N/A'}`);
});
});
console.error('\nWiki scraper failed');
process.exit(1);
} else {
console.info('\nAll Wiki pages processed successfully');
}
}
);
})();