Skip to content

Commit

Permalink
Merge pull request #30 from cvan/gh-pages-script
Browse files Browse the repository at this point in the history
gh-pages script
  • Loading branch information
cvan committed Sep 24, 2015
2 parents 7e2a9b8 + 43c86ea commit 2cde375
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ If you'd like to hack on this project and don't have access to the npm repos, co
npm login

And fire up __[http://localhost:9000](http://localhost:9000)__!


## Publishing to GitHub Pages

To publish to __https://mozvr.github.io/vr-components/__:

npm run ghpages

To publish to __https://cvan.github.io/vr-components/__:

npm run ghpages cvan
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
"browserify": "browserify ./index.js -s 'vr-components' -t browserify-css",
"build": "mkdir -p build/ && npm run browserify -- --debug -o build/vr-components.js",
"dist": "mkdir -p dist/ && npm run browserify -- --debug -o dist/vr-components.js && uglifyjs dist/vr-components.js -c warnings=false -m -o dist/vr-components.min.js",
"replacepaths": "replace 'build/vr-components.js' 'dist/vr-components.min.js' gh-pages/ -r",
"preghpages": "npm run dist && rm -rf gh-pages && mkdir -p gh-pages && cp -r {.nojekyll,dist,lib,examples,index.html,style} gh-pages/. && git checkout dist/ && replace 'build/vr-components.js' 'dist/vr-components.min.js' gh-pages/ -r --silent",
"ghpages": "node ./scripts/gh-pages",
"gh-pages": "npm run ghpages",
"preghpages": "mkdir -p gh-pages && cp -r {.nojekyll,dist,lib,examples,index.html,style} gh-pages/. && npm run replacepaths",
"ghpages": "gh-pages -d gh-pages && rm -rf gh-pages",
"release": "npm version patch --minor && npm login && npm publish",
"lint": "semistandard -v $(git ls-files '*.js') | snazzy",
"precommit": "npm run lint"
Expand Down
63 changes: 63 additions & 0 deletions scripts/gh-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

/**
* Fancy script to deploy to GitHub Pages
* ======================================
*
* Sample usage
* ------------
*
* % node ./scripts/gh-pages
* gh-pages -d dist -r git@github.com:MozVR/vr-components.git
*
* % node ./scripts/gh-pages cvan
* gh-pages -d dist -r git@github.com:cvan/vr-components.git
*
* % node ./scripts/gh-pages git@github.com:dmarcos/vr-components.git
* gh-pages -d dist -r git@github.com:dmarcos/vr-components.git
*
*/

var spawn = require('child_process').spawn;

var ghpages = require('gh-pages');
var path = require('path');

var repo = {
username: 'MozVR',
name: 'vr-components'
};

var arg = process.argv[2];
if (arg) {
if (arg.indexOf(':') === -1) {
repo.username = arg;
} else {
repo.url = arg;
var usernameMatches = arg.match(':(.+)/');
if (usernameMatches) {
repo.username = usernameMatches[1];
}
}
}

if (!repo.url) {
repo.url = 'git@github.com:' + repo.username + '/' + repo.name + '.git';
}

repo.ghPagesUrl = 'https://' + repo.username + '.github.io/' + repo.name + '/';

console.log('Publishing to', repo.url);

ghpages.clean();
ghpages.publish(path.join(process.cwd(), 'gh-pages'), {
repo: repo.url,
dotfiles: true,
logger: function (message) {
console.log(message);
}
}, function () {
console.log('Published');
console.log(repo.ghPagesUrl);
spawn('open', [repo.ghPagesUrl]);
});

0 comments on commit 2cde375

Please sign in to comment.