Skip to content

Commit 197f730

Browse files
satyarohithehmicky
andauthored
feat: deploy actions in parallel (#42)
Co-authored-by: ehmicky <[email protected]>
1 parent bfffb2d commit 197f730

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

index.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,27 @@ async function deployProject(run) {
2828
*/
2929
async function deployActions({run, functionsDir, timeout, memory}) {
3030
const files = await readdir(functionsDir);
31-
for (const file of files) {
32-
const [actionName, extension] = file.split('.');
33-
let command =
34-
`nim action update ${actionName} ${join(functionsDir, file)} ` +
35-
`--timeout=${Number(timeout)} --memory=${Number(memory)} ` +
36-
`--web=raw `;
37-
38-
if (extension === 'js') {
39-
command += '--kind nodejs-lambda:10 --main handler';
40-
}
4131

42-
// Deploy
43-
console.log(`Deploying ${file}...`);
44-
// eslint-disable-next-line no-await-in-loop
45-
const {stdout, stderr, exitCode} = await run.command(command, {
46-
reject: false,
47-
stdout: 'ignore'
48-
});
49-
50-
if (exitCode === 0) {
51-
console.log('done.');
52-
} else {
53-
console.log(stdout || stderr);
54-
}
55-
}
32+
await Promise.all(
33+
files.map(async (file) => {
34+
const [actionName, extension] = file.split('.');
35+
let command =
36+
`nim action update ${actionName} ${join(functionsDir, file)} ` +
37+
`--timeout=${Number(timeout)} --memory=${Number(memory)} ` +
38+
`--web=raw `;
39+
40+
if (extension === 'js') {
41+
command += '--kind nodejs-lambda:10 --main handler';
42+
}
43+
44+
const {stderr, exitCode} = await run.command(command, {
45+
reject: false,
46+
stdout: 'ignore'
47+
});
48+
const message = exitCode === 0 ? 'done.' : String(stderr);
49+
console.log(`Deploying ${file}: ${message}`);
50+
})
51+
);
5652
}
5753

5854
module.exports = {

0 commit comments

Comments
 (0)