Skip to content

Commit 19568b4

Browse files
committed
Add -b/--basedir option
Based on a patch by Breeze.kay <wangwenpei@nextoa.com> in #18. Closes #16. Closes #18. Addresses pugjs/pug#2164.
1 parent 2a7addb commit 19568b4

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
As with most npm modules, this project adheres to
33
[Semantic Versioning](http://semver.org/).
44

5+
## [1.0.0] - 2016-06-01
6+
7+
### Added
8+
- `--basedir` option is added for easier specification of that Pug option.
9+
- Mark as stable.
10+
511
## [1.0.0-alpha5] - 2016-05-18
612

713
### Changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ program
3131
.option('-O, --obj <str|path>', 'JSON/JavaScript options object or file')
3232
.option('-o, --out <dir>', 'output the rendered HTML or compiled JavaScript to <dir>')
3333
.option('-p, --path <path>', 'filename used to resolve includes')
34-
.option('-P, --pretty', 'compile pretty html output')
35-
.option('-c, --client', 'compile function for client-side runtime.js')
34+
.option('-b, --basedir <path>', 'path used as root directory to resolve absolute includes')
35+
.option('-P, --pretty', 'compile pretty HTML output')
36+
.option('-c, --client', 'compile function for client-side')
3637
.option('-n, --name <str>', 'the name of the compiled template (requires --client)')
3738
.option('-D, --no-debug', 'compile without debugging (smaller functions)')
3839
.option('-w, --watch', 'watch files for changes and automatically re-render')
@@ -107,6 +108,7 @@ function parseObj (input) {
107108
['debug', 'compileDebug'], // --no-debug
108109
['client', 'client'], // --client
109110
['pretty', 'pretty'], // --pretty
111+
['basedir', 'basedir'], // --basedir
110112
['doctype', 'doctype'], // --doctype
111113
].forEach(function (o) {
112114
options[o[1]] = program[o[0]] !== undefined ? program[o[0]] : options[o[1]];

test/dependencies/dependency1.pug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
html
2+
body
3+
block container

test/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ describe('HTML output', function () {
161161
done();
162162
});
163163
});
164+
it('--basedir', function (done) {
165+
w('input.pug', 'extends /dependency1.pug');
166+
w('input.html', '<p>output not written</p>');
167+
run(['--no-debug', '-b', j([__dirname, 'dependencies']), 'input.pug'], function (err, stdout) {
168+
if (err) return done(err);
169+
var html = r('input.html');
170+
assert.equal(html, '<html><body></body></html>');
171+
done();
172+
});
173+
});
164174
context('--obj', function () {
165175
it('JavaScript syntax works', function (done) {
166176
w('input.pug', '.foo= loc');

0 commit comments

Comments
 (0)