├── .gitignore ├── bin ├── push.js ├── deploy.js ├── commit.js └── github-pages.js ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /bin/push.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | var shell = require("shelljs"); 3 | 4 | shell.exec("git push origin master --force"); 5 | -------------------------------------------------------------------------------- /bin/deploy.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | var shell = require("shelljs"); 3 | 4 | shell.exec("github-pages-commit && github-pages-push"); 5 | -------------------------------------------------------------------------------- /bin/commit.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | var shell = require("shelljs"); 3 | 4 | shell.exec("git add -A . && git commit -a -m 'gh-pages update'"); 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@linclark/github-pages-deploy", 3 | "version": "2.0.0", 4 | "dependencies": { 5 | "shelljs": "^0.4.0", 6 | "yargs": "^3.9.0" 7 | }, 8 | "bin": { 9 | "github-pages": "bin/github-pages.js" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Read the article 2 | 3 | [Building a simple command line tool with npm](http://blog.npmjs.org/post/118810260230/building-a-simple-command-line-tool-with-npm) 4 | 5 | ## Run the example 6 | 7 | 1. In your project, run `npm install --save @linclark/github-pages-deploy` 8 | 1. In your project's `package.json` file, add a scripts key 9 | 10 | ``` 11 | "scripts": { 12 | "deploy": "github-pages-deploy" 13 | }, 14 | ``` 15 | -------------------------------------------------------------------------------- /bin/github-pages.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var shell = require("shelljs"); 4 | var yargs = require("yargs"); 5 | 6 | var argv = yargs.usage("$0 command") 7 | .command("commit", "commit changes to the repo", function (yargs) { 8 | shell.exec("git add -A . && git commit -a -m 'gh-pages update'"); 9 | }) 10 | .command("push", "push changes up to GitHub", function (yargs) { 11 | shell.exec("git push origin master --force"); 12 | }) 13 | .command("deploy", "commit and push changes in one step", function (yargs) { 14 | shell.exec("github-pages commit && github-pages push"); 15 | }) 16 | .demand(1, "must provide a valid command") 17 | .help("h") 18 | .alias("h", "help") 19 | .argv 20 | --------------------------------------------------------------------------------