From 6412a7dac37ba901f8d336057784d933ae5de7e3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 8 May 2015 11:38:45 +0800 Subject: [PATCH] Support command line gh-pages -d dist -b master --- bin/gh-pages | 25 +++++++++++++++++++++++++ package.json | 14 +++++++++----- readme.md | 30 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 5 deletions(-) create mode 100755 bin/gh-pages diff --git a/bin/gh-pages b/bin/gh-pages new file mode 100755 index 0000000..cd525bb --- /dev/null +++ b/bin/gh-pages @@ -0,0 +1,25 @@ +#!/usr/bin/env node + +var ghpages = require('../lib/index'); +var program = require('commander'); +var path = require('path'); + +program + .version(require('../package').version) + .option('-d, --dist ', + 'base directory for all source files') + .option('-s, --src ', + 'pattern used to select which files should be published', '**/*') + .option('-b, --branch ', + 'name of the branch you\'ll be pushing to', 'gh-page') + .parse(process.argv); + +ghpages.publish(path.join(process.cwd(), program.dist), { + branch: program.branch, + src: program.src, + logger: function(message) { + console.log(message); + } +}, function() { + console.log('Published'); +}); diff --git a/package.json b/package.json index e864fa8..c84e4ce 100644 --- a/package.json +++ b/package.json @@ -30,17 +30,21 @@ "test": "node tasks.js lint test" }, "dependencies": { + "async": "0.2.9", + "commander": "~2.8.1", + "glob": "~4.0.2", + "graceful-fs": "2.0.1", + "lodash": "~2.4.1", "q": "~1.0.1", "q-io": "~1.11.0", - "graceful-fs": "2.0.1", - "async": "0.2.9", - "wrench": "1.5.1", - "lodash": "~2.4.1", - "glob": "~4.0.2" + "wrench": "1.5.1" }, "devDependencies": { "mocha": "~1.18.2", "jshint": "~2.4.4", "chai": "~1.9.1" + }, + "bin": { + "gh-pages": "bin/gh-pages" } } diff --git a/readme.md b/readme.md index b60d4cb..b7cd575 100644 --- a/readme.md +++ b/readme.md @@ -286,3 +286,33 @@ ghpages.publish(path.join(__dirname, 'build'), { Note that this plugin requires Git 1.7.6 or higher (because it uses the `--exit-code` option for `git ls-remote`). If you'd like to see this working with earlier versions of Git, please [open an issue](https://github.com/tschaub/gh-pages/issues). [![Current Status](https://secure.travis-ci.org/tschaub/gh-pages.png?branch=master)](https://travis-ci.org/tschaub/gh-pages) + +## Cli + +`gh-pages` can be used in Command line. + +1. Scripts + + ```shell + "scripts": { + "deploy": "npm run gh-pages", + "gh-pages": "gh-pages -d dist -b gh-pages" + } + ``` + + ```shell + npm run deploy + ``` + +2. Global + + ```shell + npm install gh-pages -g + gh-pages -d dist -b gh-pages + ``` + +Cli support options below: + +* `-d --dir` basePath +* `-s --src` options.src +* `-b --branch` options.branch