adapt-cli icon indicating copy to clipboard operation
adapt-cli copied to clipboard

Unable to call install command multiple times

Open tomgreenfield opened this issue 3 years ago • 0 comments

Error

Copied from https://github.com/adapt-security/adapt-authoring/issues/280:

We're currently not able to run the CLI in parallel, as errors are thrown (think this could be caused by some kind of global scope).

An array of promises is being returned for each invocation of the install command when run in parallel, instead of a single resolved/rejected promise.

To reproduce

In framework directory:

  1. Add installParallel.js:

    (async function() {
      const cli = require('adapt-cli').api.commands;
      const plugins = [
        'adapt-contrib-accordion',
        'adapt-contrib-slider',
        'adapt-contrib-vanilla'
      ];
      const results = await Promise.allSettled(plugins.map(plugin => cli.install(plugin)));
      results.forEach((result, i) => console.log(plugins[i], result.value || result.reason));
    }());
    
  2. Run:

    npm install adapt-cli
    node installParallel
    

tomgreenfield avatar Apr 27 '21 11:04 tomgreenfield