jsw0528/jekyll-cli

View on GitHub
bin/jekyll

Summary

Maintainability
Test Coverage
#!/usr/bin/env node

/*jshint node:true, asi:true, expr:true */

'use strict';

var jkl = require('commander')
var join = require('path').join
var path = function(file) { return join('..', 'lib', file) }

jkl
  .command('new <PATH>')
  .description('Creates a new Jekyll site scaffold in PATH')
  .option('-B, --no-bundle', 'Do not run bundle install')
  .action(require(path('new')))

jkl
  .command('post <TITLE>')
  .description('Create a new post')
  .option('-d, --drafts', 'As a draft')
  .option('--ext <NAME>', 'Specify the extension name (Defaults to md)', 'md')
  .option('-p, --pinyin', 'Change Chinese into pinyin')
  .action(require(path('post')))

jkl
  .command('watch')
  .description('Watch the changes locally')
  .option('-o, --open', 'Open the website using your default browser')
  .option('-p, --port <PORT>', 'Port to listen on')
  .option('-D, --no-drafts', 'Excludes the drafts')
  .action(require(path('watch')))

jkl
  .command('sass')
  .description('Compile Sass stylesheets')
  .option('-w, --watch', 'Auto compile when Sass stylesheets change')
  .action(require(path('sass')))

jkl
  .command('git')
  .description('Setup git repository')
  .action(require(path('git')))

jkl
  .command('deploy')
  .description('Deploy to GitHub')
  .option('-m <MESSAGE>', 'Use the given MESSAGE as the commit message.', ':u7121:')
  .action(require(path('deploy')))

jkl.parse(process.argv)

if (jkl.rawArgs.length == 2) {
  jkl.help()
}