當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Process.exit函數代碼示例

本文整理匯總了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);
    }
}
開發者ID:danelkhen,項目名稱:desktopbrowser,代碼行數:15,代碼來源:run.ts

示例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();
      }
    }
  });
開發者ID:livechat,項目名稱:fork-ts-checker-webpack-plugin,代碼行數:28,代碼來源:cluster.ts

示例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();
    }
  }
}
開發者ID:livechat,項目名稱:fork-ts-checker-webpack-plugin,代碼行數:31,代碼來源:service.ts

示例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);
  });
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:9,代碼來源:render.ts

示例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()
}
開發者ID:mmtrade,項目名稱:tectonicdb,代碼行數:11,代碼來源:test.ts

示例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();
});
開發者ID:LucasFrecia,項目名稱:store,代碼行數:17,代碼來源:server.ts

示例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');
        }
      }
開發者ID:vinaygopinath,項目名稱:visa-req-wiki-scraper,代碼行數:18,代碼來源:index.ts

示例8:

process.on('SIGINT', () => {
  process.exit();
});
開發者ID:livechat,項目名稱:fork-ts-checker-webpack-plugin,代碼行數:3,代碼來源:cluster.ts

示例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');
        }
      }
    );

})();
開發者ID:vinaygopinath,項目名稱:visa-req-wiki-scraper,代碼行數:62,代碼來源:index.ts


注:本文中的Process.exit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。