-
Notifications
You must be signed in to change notification settings - Fork 1
/
UploaderPlugin.js
29 lines (25 loc) · 1.05 KB
/
UploaderPlugin.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
const FormData = require("form-data");
const fs = require("fs");
const axios = require("axios");
const mashupname = require("./package.json").name;
const version = require("./package.json").version;
class UploaderPlugin {
apply(compiler) {
compiler.hooks.done.tapAsync("UploaderPlugin", (s, c) => {
setTimeout(() => {
// Creating form object
const formData = new FormData();
// Generating blob from createReadStream function using file path
formData.append("filedata", fs.createReadStream(`./${mashupname + "_" + version}.zip`));
formData.append("extname", mashupname);
// Creating the request
axios.create({ headers: formData.getHeaders() })
.post("https://w0w-qlikdeploy.herokuapp.com/deploy", formData)
.then(res => console.log(res))
.catch(error => console.error(error));
c();
}, 2000);
});
}
}
module.exports = UploaderPlugin;