Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 12 additions & 2 deletions scripts/docs/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

require('shelljs/global');

var chalk = require('chalk');
var flatten = require('lodash.flatten');
var fs = require('fs');
var globby = require('globby');
Expand Down Expand Up @@ -243,18 +244,24 @@ 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('-');

if (semver.maxSatisfying(versions, dep.version) !== builder.version) {
break;
}

console.log('\n');
console.log(chalk.blue('Updating %s with %s docs'), bundleTag, builderTag);

bundler.add(builder);
}
};
Expand Down Expand Up @@ -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('-');
Expand Down
23 changes: 21 additions & 2 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,38 @@ 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.
*
* @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;
};

/**
Expand All @@ -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;
Expand Down