forked from stuartsan/cypress-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 847 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const fs = require("fs");
const AWS = require("aws-sdk");
const glob = require("glob");
const lambda = new AWS.Lambda({ region: "us-west-2" });
const lambdaArn = fs.readFileSync("./deployed_lambda_arn").toString();
async function main() {
const files = glob
.sync("cypress/integration/**/*.spec.js", {
cwd: "lambda"
})
.map(file => `/tmp/${file}`);
try {
const results = await Promise.all(
files.map(file => {
return lambda
.invoke({
FunctionName: lambdaArn,
Payload: JSON.stringify({ cypressSpec: file })
})
.promise();
})
);
results.forEach((result, idx) => {
fs.writeFileSync(
`reports/mochawesome-${idx}.json`,
JSON.parse(result.Payload)
);
});
} catch (e) {
console.error(e);
}
}
main();