当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript promisify-node类代码示例

本文整理汇总了TypeScript中promisify-node的典型用法代码示例。如果您正苦于以下问题:TypeScript promisify-node类的具体用法?TypeScript promisify-node怎么用?TypeScript promisify-node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了promisify-node类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getRepos

/**
 * Returns a Promise of a list of Polymer github repos to automatically
 * cleanup / transform.
 */
async function getRepos(): Promise<GitHub.Repo[]> {
  const per_page = 100;
  const getFromOrg: (o: Object) => Promise<GitHub.Repo[]> =
      promisify(github.repos.getFromOrg);
  let progressLength = 2;
  if (opts.repo.length) {
    progressLength += opts.repo.length
  }
  const progressBar = standardProgressBar(
      'Discovering repos in PolymerElements...', progressLength);

  // First get the Polymer repo, then get all of the PolymerElements repos.
  const repo: GitHub.Repo =
      await promisify(github.repos.get)({user: 'Polymer', repo: 'polymer'});
  progressBar.tick();
  const repos = [repo];
  if (opts.repo.length) {
    // cleanup passes wants ContributionGuide around
    repos.push(
        await promisify(github.repos.get)(
            {user: 'PolymerElements', repo: 'ContributionGuide'}));
    progressBar.tick();
    for (let repo of opts.repo) {
      repos.push(await promisify(github.repos.get)(repo));
      progressBar.tick();
    }
  } else {
    let page = 0;
    while (true) {
      const resultsPage =
          await getFromOrg({org: 'PolymerElements', per_page, page});
      repos.push.apply(repos, resultsPage);
      page++;
      if (resultsPage.length < per_page) {
        break;
      }
    }
    repos.push(
        await promisify(github.repos.get)(
            {user: 'PolymerLabs', repo: 'promise-polyfill'}));
    progressBar.tick();
  }

  // github pagination is... not entirely consistent, and
  // sometimes gives us duplicate repos.
  const repoIds = new Set<string>();
  const dedupedRepos: GitHub.Repo[] = [];
  for (const repo of repos) {
    if (repoIds.has(repo.name)) {
      continue;
    }
    repoIds.add(repo.name);
    dedupedRepos.push(repo);
  }
  return dedupedRepos;
}
开发者ID:BruceZu,项目名称:tedium,代码行数:60,代码来源:tedium.ts

示例2: getRepos

/**
 * Returns a Promise of a list of Polymer github repos to automatically
 * cleanup / transform.
 */
async function getRepos(): Promise<GitHub.Repo[]> {
  const per_page = 100;
  const getFromOrg = promisify(github.repos.getFromOrg);
  const getRepo = promisify(github.repos.get);
  let progressLength = 2;
  if (opts.repo.length) {
    progressLength += opts.repo.length;
  }
  const progressBar = standardProgressBar(
      'Discovering repos in PolymerElements...', progressLength);

  const repos: GitHub.Repo[] = [];

  // First get the repos outside PolymerElements, and those that are always
  // needed.
  const repoPromises = [
    // getRepo({user: 'Polymer', repo: 'polymer'}),
    // getRepo({user: 'PolymerLabs', repo: 'promise-polyfill'}),
    // getRepo({user: 'PolymerElements', repo: 'ContributionGuide'})
  ];

  if (opts.repo.length) {
    for (const repo of opts.repo) {
      repoPromises.push(getRepo(repo));
    }
  } else {
    let page = 0;
    while (true) {
      const resultsPage =
          await getFromOrg({org: 'PolymerElements', per_page, page});
      repos.push.apply(repos, resultsPage);
      page++;
      if (resultsPage.length < per_page) {
        break;
      }
    }

    progressBar.tick();
  }

  repos.push(...await Promise.all(repoPromises));
  progressBar.tick();
  // github pagination is... not entirely consistent, and
  // sometimes gives us duplicate repos.
  const repoIds = new Set<string>();
  const dedupedRepos: GitHub.Repo[] = [];
  for (const repo of repos) {
    if (repoIds.has(repo.name)) {
      continue;
    }
    repoIds.add(repo.name);
    dedupedRepos.push(repo);
  }
  return dedupedRepos;
};
开发者ID:TimvdLippe,项目名称:tedium,代码行数:59,代码来源:tedium.ts

示例3: detect

export async function detect(): Promise<{[browser: string]: wd.Capabilities}> {
  const launcher = await promisify(launchpad.local)();
  const browsers = await promisify(launcher.browsers)();

  const results: {[browser: string]: wd.Capabilities} = {};
  for (const browser of browsers) {
    if (!LAUNCHPAD_TO_SELENIUM[browser.name]) continue;
    const converter = LAUNCHPAD_TO_SELENIUM[browser.name];
    results[browser.name] = converter(browser);
  }

  return results;
}
开发者ID:nelsonsilva,项目名称:wct-local,代码行数:13,代码来源:browsers.ts

示例4: expandDirectory

async function expandDirectory(
    baseDir: string, aPath: string): Promise<string[]> {
  const stat = await promisify(fs.stat)(path.resolve(baseDir, aPath));
  if (!stat.isDirectory()) {
    return [aPath];
  }
  const files = await promisify(fs.readdir)(path.resolve(baseDir, aPath));
  // We have an index; defer to that.
  if (_.includes(files, 'index.html')) {
    return [path.join(aPath, 'index.html')];
  }
  const children = await expandDirectories(path.join(baseDir, aPath), files);
  return children.map((child) => path.join(aPath, child));
}
开发者ID:fearphage,项目名称:web-component-tester,代码行数:14,代码来源:paths.ts

示例5: seleniumStart

async function seleniumStart(
      wct: wct.Context,
      opts: {args: string[], install: boolean}): Promise<number> {
  const port = await promisify(freeport)();

  // See below.
  const log: string[] = [];
  function onOutput(data: any) {
    const message = data.toString();
    log.push(message);
    wct.emit('log:debug', message);
  }

  const config: selenium.StartOpts = SELENIUM_OVERRIDES || {};
  config.seleniumArgs = ['-port', port.toString()].concat(opts.args);
  // Bookkeeping once the process starts.
  config.spawnCb = function(server: child_process.ChildProcess) {
    // Make sure that we interrupt the selenium server ASAP.
    cleankill.onInterrupt(function(done) {
      server.kill();
      done();
    });

    server.stdout.on('data', onOutput);
    server.stderr.on('data', onOutput);
  };

  if (opts.install) {
    try {
      const options = SELENIUM_OVERRIDES || {};
      options.logger = onOutput;
      await promisify(selenium.install)(options);
    } catch (error) {
      log.forEach((line) => wct.emit('log:info', line));
      throw error;
    }
  }

  try {
    await promisify(selenium.start)(config);
  } catch (error) {
    log.forEach((line) => wct.emit('log:info', line));
    throw error;
  }

  wct.emit(
      'log:info',
      'Selenium server running on port', chalk.yellow(port.toString()));
  return port;
}
开发者ID:jasongardnerlv,项目名称:wct-local,代码行数:50,代码来源:selenium.ts

示例6: run

async function run() {
    // Load configuration
    nconf.argv()
        .env({ separator: "_" })
        .file("user", { file: process.env.SMU_CONFIG || "/etc/smu.yml", format: nconfYaml })
        .file("defaults", { file: join(__dirname, "../conf/defaults.yml"), format: nconfYaml });

    const config = nconf.get(null);

    // Initialize Hapi
    const server = promisify(new hapi.Server());
    server.connection(config.server);

    // init server
    try {
        await server.register(plugins);
        setupAuthentication(server, config.authentication);
        setupCommands(server, config.commands);
        await server.start();
    } catch (err) {
        server.log(["error"], "Error starting server: " + err);
        process.exit(1);
    }
    server.log(["info"], `Server running at: ${server.info.uri}`);
}
开发者ID:msurdi,项目名称:smu,代码行数:25,代码来源:index.ts

示例7: detect

export let detect = async function detect(browserOptions: {[name: string]: string[]}): Promise<{[browser: string]: wd.Capabilities}> {
  const launcher = await promisify(launchpad.local)();
  const browsers = await promisify(launcher.browsers)();

  const results: {[browser: string]: wd.Capabilities} = {};
  for (const browser of browsers) {
    if (!LAUNCHPAD_TO_SELENIUM[browser.name]) continue;
    const converter = LAUNCHPAD_TO_SELENIUM[browser.name];
    const convertedBrowser = converter(browser, browserOptions && browserOptions[browser.name]);
    if (convertedBrowser) {
      results[browser.name] = convertedBrowser;
    }
  }

  return results;
};
开发者ID:MehdiRaash,项目名称:tools,代码行数:16,代码来源:browsers.ts

示例8: unglob

/**
 * Expands any glob expressions in `patterns`.
 *
 * @param {string} baseDir
 * @param {!Array<string>} patterns
 */
async function unglob(baseDir: string, patterns: string[]): Promise<string[]> {
  const strs: string[][] = [];
  const pGlob: any = promisify(glob);
  for (const pattern of patterns) {
    strs.push(await pGlob(String(pattern), {cwd: baseDir, root: baseDir}));
  }
  return  _.union(_.flatten(strs));
}
开发者ID:digideskio,项目名称:web-component-tester,代码行数:14,代码来源:paths.ts

示例9: unglob

/**
 * Expands any glob expressions in `patterns`.
 */
async function unglob(baseDir: string, patterns: string[]): Promise<string[]> {
  const strs: string[][] = [];
  const pGlob: any = promisify(glob);
  for (const pattern of patterns) {
    strs.push(await pGlob(String(pattern), {cwd: baseDir, root: baseDir}));
  }

  // for non-POSIX support, replacing path separators
  return _.union(_.flatten(strs)).map((str) => str.replace(/\//g, path.sep));
}
开发者ID:MehdiRaash,项目名称:tools,代码行数:13,代码来源:paths.ts

示例10: promisify

export async function checkSeleniumEnvironment(): Promise<void> {
  try {
    await promisify(which)('java');
    return;
  } catch (error) { /* Handled below */ }

  let message = 'java is not present on your PATH.';
  if (process.platform === 'win32') {
    message += `\n\n  Please install it: https://java.com/download/\n\n`;
  } else if (process.platform === 'linux') {
    try {
      await promisify(which)('apt-get');
      message = message + '\n\n  sudo apt-get install default-jre\n\n';
    } catch (error) {
      // There's not a clear default package for yum distros.
    }
  }

  throw message;
}
开发者ID:MehdiRaash,项目名称:tools,代码行数:20,代码来源:selenium.ts


注:本文中的promisify-node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。