How to use the promise.series function in promise

To help you get started, we’ve selected a few promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github egoist / use-config / index.js View on Github external
load() {
    if (typeof this.options.name !== 'string') {
      return Promise.reject(
        new TypeError('[use-config] Expect "name" to be a string')
      )
    }

    const fallbackLoader = filepath => loadJsonFile(filepath)

    return series(
      this.options.files.map(_file => {
        return result => {
          // Pass this action when config is already retrived
          if (result.path && result.config) return result

          const file = pupa(_file, { name: this.options.name })
          const filepath = resolve(this.options.cwd, file)
          return pathExists(filepath).then(exists => {
            if (!exists) return result

            const loader = this.findLoader(filepath) || fallbackLoader

            return Promise.resolve(loader(filepath)).then(config => {
              // When config is falsy
              // We think it's an invalid config file
              return config
github axa-ch / patterns-library / stack / tasks / release.js View on Github external
const execaSeries = args => promiseSeries(args
  .filter(arg => typeof arg === 'string' && arg.length)
  .map(arg => () => execaPipeError(arg)));

console.log(chalk.cyan(outdent`

  🚀  Hello Dear developer, welcome to the release assistant. 🚀

  !! Please make sure you have no changes to be commited !!

  I'm getting some information....

  `));

promiseSeries([
  () => execaPipeError('npm whoami')
    .then(({ stdout }) => stdout)
    .catch((reason) => {
      console.log(chalk.red(outdent`

        Attention: You are currently not logged into npm. I will abort the action

        Please login:

        ${chalk.bold('npm login')}

      `));

      throw reason;
    }),
  whoami => execaPipeError('npm owner ls')
github axa-ch / patterns-library / stack / tasks / release.js View on Github external
}),
      () => execaSeries([
        `git checkout ${DEVELOP_TRUNK} --quiet`,
        `git merge --ff-only ${MASTER_TRUNK}`,
        'git push',
        'git push --tags',
      ]).then(() => {
        console.log(chalk.cyan(outdent`
            Step 6 complete! Publishing done successfully. Have fun!

          `));
      }),
    ];
  }

  promiseSeries(releaseSteps)
    .then(() => {
      generalCleanupHandling(0);
    })
    .catch((reason) => {
      console.error(chalk.red(reason));

      generalCleanupHandling(1);
    });
};
github axa-ch / patterns-library / stack / tasks / release.js View on Github external
const execaSeries = args => promiseSeries(args
  .filter(arg => typeof arg === 'string' && arg.length)
  .map(arg => () => execaPipeError(arg)));
github TimBroddin / cryptocoincount / server / lib / populate.js View on Github external
getAllCoins().then(ids => {
      const promises = [];
      ids.forEach((id, k) => promises.push(() => fetchHistory(id, CoinHistory, k+1, ids.length)));
      promiseSeries(promises).then(() => {
        resolve();
      });
    }).catch(reject);
  })
github egoist / taki / lib / chrome.js View on Github external
module.exports = opts => {
  const chromy = new Chromy()

  const handleResult = result => {
    return chromy.close().then(() => result)
  }

  const handleError = err => {
    if (chromy && chromy.close) {
      chromy.close()
    }
    throw err
  }

  if (Array.isArray(opts.url)) {
    return series(
      opts.url.map(url => () => {
        return fetch(Object.assign({}, opts, { url }), chromy)
      })
    ).then(handleResult, handleError)
  }

  return fetch(opts, chromy).then(handleResult, handleError)
}
github egoist / rollup-plugin-postcss / src / loaders.js View on Github external
process({ code, map }, context) {
    return series(
      this.use
        .slice()
        .reverse()
        .map(([name, options]) => {
          const loader = this.getLoader(name)
          const loaderContext = Object.assign(
            {
              options: options || {}
            },
            context
          )

          return v => {
            if (
              loader.alwaysProcess ||
              matchFile(loaderContext.id, loader.test)