nimbella/netlify-plugin-nimbella

Performance: consider uploading files in parallel

Closed this issue · 3 comments

Could this loop be done in parallel?

for (const file of files) {

Considering this uploads files it could improve performance.

I tried to achieve this but the output was a bit distorted. Would be a nice improvement for a future release. Thanks for your suggestion. :)

Removing the initial Deploy ${file}... might help make the logs less distorted:

await Promise.all(files.map(async file => {
  const [actionName, extension] = file.split('.');
  let command =
    `nim action update ${actionName} ${join(functionsDir, file)} ` +
    `--timeout=${Number(timeout)} --memory=${Number(memory)} ` +
    `--web=raw `;

  if (extension === 'js') {
    command += '--kind nodejs-lambda:10 --main handler';
  }

  // Note: since stdout: 'ignore' is used, the returned `stdout` will always be empty
  const {stderr, exitCode} = await run.command(command, { reject: false, stdout: 'ignore' });
  const message = exitCode === 0 ? 'done.' : String(stderr)
  console.log(`Deployed ${file}: ${message}`)
}))

If the files must be sorted in the logs, it could also be possible to do a single console.log() after all files have been deployed.

Thanks for the suggestion, @ehmicky! :)