diff --git a/package.json b/package.json index d439491ac3d..fcb9f1300b4 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "devDependencies": { "array-uniq": "^1.0.3", "async": "^2.0.1", + "chalk": "^1.1.3", "coveralls": "^2.11.2", "create-error-class": "^3.0.2", "david": "^9.0.0", diff --git a/scripts/docs/builder.js b/scripts/docs/builder.js index da0ec3bfb3c..5526f2c160d 100644 --- a/scripts/docs/builder.js +++ b/scripts/docs/builder.js @@ -18,6 +18,7 @@ require('shelljs/global'); +var chalk = require('chalk'); var flatten = require('lodash.flatten'); var fs = require('fs'); var globby = require('globby'); @@ -243,11 +244,14 @@ Bundler.updateDep = function(builder) { var bundleVersions = bundleConfig.versions; var config = findWhere(manifest.modules, { id: builder.name }); var versions = config.versions.filter(semver.valid); - var bundler, dep; + var builderTag = builder.getTagName(); + var bundler, dep, bundleTag; for (var i = 0; i < bundleVersions.length - 1; i++) { bundler = new Bundler(bundleVersions[i]); - git.checkout(bundler.builder.getTagName()); + bundleTag = bundler.builder.getTagName(); + git.checkout(bundleTag); + dep = findWhere(bundler.getDeps(), { name: builder.name }); git.checkout('-'); @@ -255,6 +259,9 @@ Bundler.updateDep = function(builder) { break; } + console.log('\n'); + console.log(chalk.blue('Updating %s with %s docs'), bundleTag, builderTag); + bundler.add(builder); } }; @@ -427,6 +434,9 @@ function sortByModId(a, b) { function build(name, version) { var builder = new Builder(name, version); + console.log('\n'); + console.log(chalk.blue('Building docs for %s@%s'), name, version); + git.checkout(builder.getTagName()); builder.build(); git.checkout('-'); diff --git a/scripts/helpers.js b/scripts/helpers.js index 78dd1284e2a..57ad23ede3b 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -273,9 +273,13 @@ module.exports.run = run; */ function Git(cwd) { this.cwd = cwd || ROOT_DIR; + this.branch = { + current: run('git rev-parse --abbrev-ref HEAD', { cwd: this.cwd, }) + }; } -Git.REPO = 'git@github.com:GoogleCloudPlatform/google-cloud-node.git'; +// ssh fails on AppVeyor +Git.REPO = 'https://github.com/GoogleCloudPlatform/google-cloud-node.git'; /** * Checks out a branch. @@ -283,9 +287,24 @@ Git.REPO = 'git@github.com:GoogleCloudPlatform/google-cloud-node.git'; * @param {string} branch - The branch to check out. */ Git.prototype.checkout = function(branch) { + // trying to checkout the same branch.. so we'll skip it + if (this.branch.current === branch) { + this.branch.previous = branch; + return; + } + + // checking out previous branch.. check if they are the same and skip + if (branch === '-' && this.branch.current === this.branch.previous) { + delete this.branch.previous; + return; + } + run(['git checkout', branch], { cwd: this.cwd }); + + this.branch.previous = this.branch.current; + this.branch.current = branch; }; /** @@ -304,7 +323,7 @@ Git.prototype.submodule = function(branch, alias) { var git = new Git(path.join(this.cwd, alias)); - git.branch = branch; + git.branch.current = branch; git.alias = alias; return git;