buildbranch

Publish a folder to the given build branch (like gh-pages).

buildbranch

Publish a folder to the given build branch (like gh-pages).

Usage

You can use this from the command-line or within your build system.

Command-line

First, install buildbranchglobally:

npm install buildbranch -g

Then, from your master branch, run buildbranchwith the branch and directory you want to publish. It will default to gh-pagesand www.

buildbranch gh-pages www example.com

All arguments are optional, the defaults being:

  • branch: 'gh-pages'
  • folder: `'www'´
  • domain: ''

Skipping the pre-commit hook

buildbranch will run git commitin the given branch. You might want to skip the pre-commit hook if there is one. This can be archived by adding another command line argument:

buildbranch gh-pages www example.com no-verify

Actually, anytime four arguments are passed, git commitwill be run with --no-verify, skipping the pre-commit and commit-msg hook, it does not matter if you pass no-verifyor any other non-empty string as the fourth argument.

buildbranch gh-pages www example.com no-verify

If you want to skip have --no-verifybut do not want to specify a domain, use

buildbranch gh-pages www '' no-verify

Build System

First, install buildbranchas a development dependency:

npm install buildbranch --save-dev

Then, use it in your build system:

buildBranch({
    branch: 'gh-pages',
    remote: 'origin',
    ignore: ['.git', 'www', 'node_modules'],
    folder: 'www',
    domain: 'example.com',
    noVerify: false
  }, function(err) {
    if(err) {
      throw err;
    }
    console.log('Published!');
  });

For example in gulp you can do it like this:

var gulp = require('gulp');
var buildBranch = require('buildbranch');

gulp.task('gh', ['build'], function(done) {
  buildBranch({ folder: 'dist' }, done);
});

API

buildBranch(options, callback)

options

Type: Object

Required. An object containing the following options.

options.branch

Type: StringDefault: 'gh-pages'

The branch on wich to publish.

options.remote

Type: StringDefault: 'origin'

The remote repository on wich to publish.

options.folder

Type: StringDefault: 'www'

The folder in wich the build is.

options.domain

Type: String

The domain name that will fill the cname file.

options.cname

Type: StringDefault: 'CNAME'

The name of the file enabling custom domain name on you build platform.

options.commit

Type: StringDefault: 'Build $'

The commit label, the first $occurrence in the given string will be replaced by the current date.

options.cwd

Type: StringDefault: process.cwd()

The working directory (root of the git repo).

options.ignore

Type: Array

A list of files to ignore. 'node_modules' and '.git' will be automatically added to the ignore list.

options.noVerify

Type: BooleanDefault: false

Whether or not to add --no-verifywhen running git commit(skipping the pre-commit and commit-msg hook).

callback

Type: Function

Required. Called when the publication is done.

License

MIT

HomePage

https://github.com/nfroidure/buildbranch

Repository

https://github.com/nfroidure/buildbranch


上一篇:@microsoft/microsoft-graph-types
下一篇:grunt-cssbeautifier

相关推荐

暂无相关文章

官方社区

扫码加入 JavaScript 社区