From 27a0ec9424978d3df5d029df528ca077b3a908dd Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Tue, 3 Mar 2015 19:57:46 +1100 Subject: [PATCH] Open docs site on publish --- gulpfile.js | 33 +++++++++++++++++++++++++-------- package.json | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 0bd79d64..7b530d25 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,7 @@ // Gulp build script // ========================================================================== /*global require, __dirname*/ +/*jshint -W079 */ var fs = require("fs"), path = require("path"), @@ -20,7 +21,8 @@ var fs = require("fs"), rename = require("gulp-rename"), s3 = require("gulp-s3"), gzip = require("gulp-gzip"), - replace = require("gulp-replace"); + replace = require("gulp-replace"), + open = require("gulp-open"); var root = __dirname, paths = { @@ -190,13 +192,12 @@ gulp.task("watch", function () { gulp.watch(paths.docs.src.templates, "js"); }); -// Publish the docs site -try { - var aws = loadJSON(path.join(root, "aws.json")); -} -catch (e) { } +// Publish a version to CDN and docs +// -------------------------------------------- -var version = package.version, +// Some options +var aws = loadJSON(path.join(root, "aws.json")), +version = package.version, maxAge = 31536000, // seconds 1 year options = { cdn: { @@ -216,6 +217,7 @@ options = { }, cdnpath = new RegExp(aws.cdn.bucket + "\/(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)","gi"); +// Publish version to CDN bucket gulp.task("cdn", function () { console.log("Uploading " + version + " to " + aws.cdn.bucket); @@ -228,6 +230,7 @@ gulp.task("cdn", function () { .pipe(s3(aws.cdn, options.cdn)); }); +// Publish to Docs bucket gulp.task("docs", function () { console.log("Uploading " + version + " docs to " + aws.docs.bucket); @@ -244,6 +247,20 @@ gulp.task("docs", function () { .pipe(s3(aws.cdn, options.docs)); }); +// Open the docs site to check it's sweet +gulp.task("open", function () { + console.log("Opening " + aws.docs.bucket + "..."); + + // A file must be specified or gulp will skip the task + // Doesn't matter which file since we set the URL above + // Weird, I know... + gulp.src([paths.docs.root + "index.html"]) + .pipe(open("", { + url: "http://" + aws.docs.bucket + })); +}); + +// Do everything gulp.task("publish", function () { - run("templates", tasks.js, tasks.less, "sprite", "cdn", "docs"); + run("templates", tasks.js, tasks.less, "sprite", "cdn", "docs", "open"); }); \ No newline at end of file diff --git a/package.json b/package.json index 422f0300..0512601f 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "gulp-hogan-compile": "^0.4.1", "gulp-less": "~1.3.1", "gulp-minify-css": "~0.3.6", + "gulp-open": "^0.3.2", "gulp-rename": "^1.2.0", "gulp-replace": "^0.5.3", "gulp-s3": "^0.3.0",