-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
30 lines (26 loc) · 738 Bytes
/
Copy pathlib.js
File metadata and controls
30 lines (26 loc) · 738 Bytes
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
const request = require('request-promise-native');
const _ = require('lodash');
const forcedShutdown = (options) => {
console.error(options.error);
if(options.forceShutdown) process.exit(1);
return Promise.resolve(options);
};
const convertDataToJSON = (options) => {
return _.isObject(options.error) ? JSON.stringify(options.error, null, 2) : options.error;
};
const writeToSlack = (options) => {
const data = convertDataToJSON(options);
return request({
method: 'POST',
url: options.url,
headers: { 'Content-type': 'application/json' },
body: { text: `\`\`\`${data}\`\`\`` },
json: true
})
.then(() => options);
};
module.exports = {
forcedShutdown,
writeToSlack,
convertDataToJSON,
};