Skip to content
This repository has been archived by the owner on Jul 4, 2019. It is now read-only.

Commit

Permalink
Add s3 script
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnblk committed Mar 29, 2015
1 parent 77c56d6 commit 55eafdc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@

aws.json
1 change: 1 addition & 0 deletions css/vhs.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -5,9 +5,11 @@
"style": "index.css",
"scripts": {
"css": "cssnext index.css css/vhs.css",
"minify": "cssnext index.css css/vhs.min.css -c",
"docs:css": "cssnext docs/index.css docs/base.css",
"html": "node docs/build",
"watch:css": "cssnext index.css css/vhs.css --watch",
"s3": "npm run minify && node scripts/s3",
"serve": "http-server -p 8000",
"start": "npm run watch:css & npm run docs:css & npm run html & npm run serve"
},
Expand All @@ -34,6 +36,7 @@
"humanize-plus": "^1.5.0",
"mocha": "^2.2.1",
"postcss": "^4.0.6",
"s3": "^4.4.0",
"watch": "^0.14.0"
},
"dependencies": {
Expand Down
38 changes: 38 additions & 0 deletions scripts/s3.js
@@ -0,0 +1,38 @@

var path = require('path');
var s3 = require('s3');
var version = require('../package.json').version;

function upload() {
var options = require('../aws.json');
var params = {
localFile: path.join(__dirname, '../css/vhs.min.css'),
s3Params: {
Bucket: options.bucket,
Key: 'vhs/' + version + '/vhs.min.css',
ACL: 'public-read',
}
};

var client = s3.createClient({
s3Options: {
accessKeyId: options.key,
secretAccessKey: options.secret,
}
});

var uploader = client.uploadFile(params);
uploader.on('error', function(err) {
console.error("unable to upload:", err.stack);
});
uploader.on('progress', function() {
console.log("progress", uploader.progressMd5Amount, uploader.progressAmount, uploader.progressTotal);
});
uploader.on('end', function() {
console.log("done uploading");
});

};

upload();

0 comments on commit 55eafdc

Please sign in to comment.