-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env node | ||
|
||
var nopt = require('nopt'); | ||
var pkg = require('../package.json'); | ||
var panini = require('../index'); | ||
var vfs = require('vinyl-fs'); | ||
var path = require('path'); | ||
|
||
|
||
// Options that can be passed to commands | ||
var options = { | ||
"root": String, | ||
"layouts": String, | ||
"partials": String, | ||
"data": String, | ||
"helpers": String, | ||
"output": String, | ||
"version": String | ||
} | ||
|
||
// Shorthands for the above commands | ||
var shorthands = { | ||
"r": "--root", | ||
"l": "--layouts", | ||
"p": "--partials", | ||
"d": "--data", | ||
"h": "--helpers", | ||
"o": "--output", | ||
"v": "--version" | ||
} | ||
|
||
var parsed = nopt(options, shorthands); | ||
|
||
// cmd.args contains basic commands like "new" and "help" | ||
// cmd.opts contains options, like --libsass and --version | ||
var cmd = { | ||
args: parsed.argv.remain, | ||
opts: parsed | ||
} | ||
|
||
// No other arguments given | ||
if (typeof cmd.args[0] === 'undefined') { | ||
// If -v or --version was passed, show the version of the CLI | ||
if (typeof cmd.opts.version !== 'undefined') { | ||
process.stdout.write("Panini version " + require('../package.json').version + '\n'); | ||
} | ||
// Otherwise, just show the help screen | ||
else { | ||
panini.help(); | ||
} | ||
} | ||
|
||
// Arguments given | ||
else { | ||
vfs.src(cmd.args). | ||
pipe(panini(cmd.opts)). | ||
pipe(vfs.dest(cmd.opts.output)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
module.exports = function() { | ||
var txt = 'Usage: panini --layouts=[layoutdir] --root=[rootdir] --dest=[destdir] [other options] \'pagesglob\'\n' + | ||
'\n' + | ||
'Options: \n' + | ||
' --layouts (required) path to a folder containing layouts\n' + | ||
' --root (required) path to the root folder all pages live in\n' + | ||
' --dest (required) path to the folder compiled pages should get sent to\n' + | ||
' --partials path to root folder for partials \n' + | ||
' --helpers path to folder for additional helpers \n' + | ||
' --data path to folder for additional data \n' + | ||
'\n' + | ||
'the argument pagesglob should be a glob describing what pages you want to apply panini to.\n' + | ||
'\n' + | ||
'Example: panini --root=src/pages --layouts=src/layouts --partials=src/partials --data=src/data --output=dist \'src/pages/**/*.html\''; | ||
|
||
|
||
process.stdout.write(txt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters