-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.js
39 lines (36 loc) · 963 Bytes
/
upload.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
var AWS = require('aws-sdk');
var fs = require('fs');
var path = require('path');
var s3 = new AWS.S3();
var data = fs.readFileSync(path.resolve(__dirname, 'dist/bundle.js'));
var params = {
ACL : 'public-read',
Bucket : 'vokou',
Key : 'bundle' + process.env.TS + '.js',
Body : data
};
if (process.env.V_ENV === 'PRO') {
params.Bucket = 'vokou-pro';
}
s3.putObject(params, function(err, data) {
if (err) {
console.log('Failed');
console.log(err);
} else {
console.log('Bundle Upload Succeed');
}
// Check if vendor needs to be updated
if (process.env.UV === 'T') {
data = fs.readFileSync(path.resolve(__dirname, 'dist/vendors.js'));
params.Key = 'vendors' + process.env.TS + '.js';
params.Body = data;
s3.putObject(params, function(err, data) {
if (err) {
console.log('Failed');
console.log(err);
} else {
console.log('Vendors Upload Succeed');
}
});
}
});