Skip to content

Commit fee984c

Browse files
committed
convert to async
1 parent 5e01f0e commit fee984c

File tree

1 file changed

+30
-38
lines changed

1 file changed

+30
-38
lines changed

.evergreen/perf_send.mjs

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,33 @@ const {
2323
} = process.env;
2424

2525

26-
fs.readFile(resultFile, 'utf8')
27-
.then(
28-
results => {
29-
const body = {
30-
id: {
31-
project,
32-
version,
33-
variant,
34-
order,
35-
task_name,
36-
task_id,
37-
execution,
38-
mainline: requester === 'commit'
39-
},
40-
results: JSON.parse(results)
41-
};
42-
43-
console.log(body);
44-
return fetch(API_PATH, {
45-
method: "POST",
46-
headers: {
47-
"Content-Type": "application/json"
48-
},
49-
body: JSON.stringify(body)
50-
})
51-
}
52-
)
53-
.then(async resp => {
54-
console.log(resp);
55-
if (resp.status !== 200) {
56-
throw new Error(`Got status code: ${resp.status}\nResponse body: ${await resp.json()}`);
57-
}
58-
console.log("Successfully posted results");
59-
})
60-
.catch(e => {
61-
console.error(e);
62-
process.exit(1);
63-
});
26+
const results = await fs.readFile(resultFile, 'utf8');
27+
const body = {
28+
id: {
29+
project,
30+
version,
31+
variant,
32+
order,
33+
task_name,
34+
task_id,
35+
execution,
36+
mainline: requester === 'commit'
37+
},
38+
results: JSON.parse(results)
39+
};
40+
41+
console.log(body);
42+
43+
const resp = await fetch(API_PATH, {
44+
method: "POST",
45+
headers: {
46+
"Content-Type": "application/json"
47+
},
48+
body: JSON.stringify(body)
49+
});
50+
51+
if (resp.status !== 200) {
52+
throw new Error(`Got status code: ${resp.status}\nResponse body: ${await resp.json()}`);
53+
}
54+
55+
console.log("Successfully posted results");

0 commit comments

Comments
 (0)