Skip to content

Commit e1ed6bb

Browse files
committed
Determining which site folders are included in the added, removed, and modified files. Tested locally.
1 parent 79c2689 commit e1ed6bb

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

functions/webhookParser.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
exports.handler = function(event, context, callback) {
22

3-
const { head_commit: { added, removed, modified } } = JSON.parse(event.body)
3+
let listOfSiteFolders = ['01-JavaScript-Drum-Kit', '02-JS-and-CSS-Clock', '03-CSS-Variables'];
44

5-
/* const send = (a, r, m) => {
6-
callback(null, {
7-
statusCode: 200,
8-
body: JSON.stringify({"added": a, "removed": r, "modified": m})
9-
});
10-
} */
5+
const { head_commit: { added, removed, modified } } = JSON.parse(event.body)
116

127
const send = (a, r, m) => {
138
callback(null, {
@@ -23,9 +18,15 @@ exports.handler = function(event, context, callback) {
2318

2419
// Make sure HTTP method is POST
2520
if (event.httpMethod == 'POST') {
26-
console.log(added);
27-
console.log(removed);
28-
console.log(modified);
21+
22+
listOfSiteFolders.forEach(siteFolder => {
23+
let allFiles = added.concat(removed, modified);
24+
25+
if (allFiles.some(file => file.includes(siteFolder))) {
26+
console.log(siteFolder);
27+
}
28+
});
29+
2930
send(added, removed, modified);
3031
}
3132
}

0 commit comments

Comments
 (0)