forked from clappr/clappr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.js
20 lines (17 loc) · 807 Bytes
/
upload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* eslint-disable no-var, no-console */
var s3 = require('s3')
var fs = require('fs')
var args = require('yargs').argv
var upload = function(localDir, prefix, deleteRemoved, cb) { // eslint-disable-line no-unused-vars
var awsOptions = JSON.parse(fs.readFileSync('./aws.json'))
var client = s3.createClient({ s3Options: awsOptions })
var params = { localDir: localDir, deleteRemoved: !!deleteRemoved, s3Params: { Bucket: 'cdn.clappr.io', Prefix: prefix } }
var uploader = client.uploadDir(params)
uploader.on('error', function(err) { console.error('unable to sync:', err.stack) })
uploader.on('end', function() { console.log('done uploading for ' + prefix) })
}
var tag = args.tag || undefined
if (tag)
upload('./dist/', tag + '/', true)
else
console.warn('no tag supplied for uploading')