-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploymentTasks.js
51 lines (48 loc) · 2.03 KB
/
deploymentTasks.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
40
41
42
43
44
45
46
47
48
49
50
51
const request=require('request')
const fs = require("fs");
const config = require('./config');
module.exports={
generateQRCodes : function(){
//Generate a qrcode
var download = function(uri, filename, callback){
request.head(uri, function(err, res, body){
console.log('content-type:', res.headers['content-type']);
console.log('content-length:', res.headers['content-length']);
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
});
};
//blue (player 1)
download('http://api.qrserver.com/v1/create-qr-code/?data=CodeJoueur1&size=100x100&color=013668&bgcolor=ffffff', './qrCodes/qrCode1.png', function(){
console.log('Qr Code 1 (blue) generated');
});
//red (player 2)
download('http://api.qrserver.com/v1/create-qr-code/?data=CodeJoueur2&size=100x100&color=d40000&bgcolor=ffffff', './qrCodes/qrCode2.png', function(){
console.log('Qr Code 2 (red) generated');
});
//green (player 3)
download('http://api.qrserver.com/v1/create-qr-code/?data=CodeJoueur3&size=100x100&color=00b200&bgcolor=ffffff', './qrCodes/qrCode3.png', function(){
console.log('Qr Code 3 (green) generated');
});
//purple (player 4)
download('http://api.qrserver.com/v1/create-qr-code/?data=CodeJoueur4&size=100x100&color=7500c0&bgcolor=ffffff', './qrCodes/qrCode4.png', function(){
console.log('Qr Code 4 (purple) generated');
});
},
//Generate the register corresponding to the 4 unscanned qr codes
generateRegisterForQrCodes : function (){
// let myJsonData={
// qrCode1: "true",
// qrCode2: "true",
// qrCode3: "true",
// qrCode4: "true",
// }
let myJsonData={
qrCode1: 0,
qrCode2: 0,
qrCode3: 0,
qrCode4: 0,
}
myJsonData=JSON.stringify(myJsonData)
fs.writeFileSync(config.qrRegister, myJsonData)
}
}