Support command line

gh-pages -d dist -b master
This commit is contained in:
afc163 2015-05-08 11:38:45 +08:00
parent 3d2d0dc748
commit 6412a7dac3
3 changed files with 64 additions and 5 deletions

25
bin/gh-pages Executable file
View file

@ -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 <dist>',
'base directory for all source files')
.option('-s, --src <src>',
'pattern used to select which files should be published', '**/*')
.option('-b, --branch <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');
});

View file

@ -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"
}
}

View file

@ -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