Skip to content

Commit d4714c1

Browse files
committed
fix subfolder jade paths
1 parent 46a35df commit d4714c1

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

index.js

+17-11
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,28 @@ function gulpJadeInheritance(options) {
1717

1818
function writeStream(currentFile) {
1919
if (currentFile && currentFile.contents.length) {
20-
var currentFileOptions = _.defaults(options, {'basedir': currentFile.base});
21-
var jadeInheritance = new JadeInheritance(currentFile.path, currentFileOptions.basedir, currentFileOptions);
22-
var filepath;
23-
24-
for (var i = 0; i < jadeInheritance.files.length; i++) {
25-
filepath = options.basedir + "/" + jadeInheritance.files[i];
26-
if (_.indexOf(files, filepath) === -1) {
27-
files.push(filepath);
28-
}
29-
}
20+
files.push(currentFile);
3021
}
3122
}
3223

3324
function endStream() {
3425
if (files.length) {
35-
vfs.src(files)
26+
var jadeInheritanceFiles = [];
27+
var filesPaths = [];
28+
29+
options = _.defaults(options, {'basedir': process.cwd()});
30+
31+
_.forEach(files, function(file) {
32+
var jadeInheritance = new JadeInheritance(file.path, options.basedir, options);
33+
34+
var fullpaths = _.map(jadeInheritance.files, function (file) {
35+
return options.basedir + "/" + file;
36+
});
37+
38+
filesPaths = _.union(filesPaths, fullpaths);
39+
});
40+
41+
vfs.src(filesPaths, {'base': options.basedir})
3642
.pipe(es.through(
3743
function (f) {
3844
stream.emit('data', f);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-jade-inheritance",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Rebuild only changed jade files and all it dependencies",
55
"main": "index.js",
66
"scripts": {

test/fixtures/subfolder/fixture5.jade

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
p fixture 5

test/main.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ describe('gulp-jade-inheritance', function(done) {
2323
var fixture = getFixtureFile('fixture1.jade')
2424

2525
var fileNames = [
26-
'fixture1.jade',
27-
'fixture2.jade',
28-
'fixture3.jade'
26+
'test/fixtures/fixture1.jade',
27+
'test/fixtures/fixture2.jade',
28+
'test/fixtures/fixture3.jade'
2929
];
3030

3131
var files = [];
@@ -93,7 +93,7 @@ describe('gulp-jade-inheritance', function(done) {
9393

9494
var files = [];
9595

96-
var stream = plugin({basedir: 'test/fixtures2'});
96+
var stream = plugin({basedir: 'test/fixtures5'});
9797
stream
9898
.on('data', function (file) {
9999
files.push(file);
@@ -128,4 +128,25 @@ describe('gulp-jade-inheritance', function(done) {
128128
stream.end();
129129
});
130130
});
131+
132+
it('subfolder jade', function(done) {
133+
var fixture = getFixtureFile('subfolder/fixture5.jade')
134+
135+
var files = [];
136+
137+
var stream = plugin({basedir: 'test/fixtures'});
138+
stream
139+
.on('data', function (file) {
140+
expect(file.base).to.be.eql('test/fixtures');
141+
files.push(file);
142+
})
143+
.once('end', function() {
144+
expect(files).to.have.length(1);
145+
146+
done();
147+
});
148+
149+
stream.write(fixture);
150+
stream.end();
151+
});
131152
});

0 commit comments

Comments
 (0)