CREEATION / gulp-jade-globbing

Globbing Jade includes & extends the easy way.
https://www.npmjs.com/package/gulp-jade-globbing
MIT License
11 stars 1 forks source link

No such file or directory #9

Open delch opened 8 years ago

delch commented 8 years ago

gulpfile.js

'use strict';

let
  gulp = require('gulp'),
  jade = require('gulp-jade'),
  jadeGlob = require('gulp-jade-globbing');

const
  PATH = {
    APP          : '../application/',
    JADE         : {
      VIEWS      : '../source/jade/views/**/*.jade'
    }
  };

gulp.task('jade', function(){
  gulp
    .src(PATH.JADE.VIEWS)
    .pipe(jadeGlob())
    .pipe(jade())
    .pipe(gulp.dest(PATH.APP));
});

Terminal error:

Error: /Users/delch/Sites/frontskel/source/jade/templates/default.jade:1
  > 1| include ../components/**/*.jade
    2| 
    3| doctype html
    4| - var title = 'Untitled page'

ENOENT: no such file or directory, open '/Users/delch/Sites/frontskel/source/jade/components/**/*.jade'
sanjinc commented 8 years ago

Same problem here, seems the thing doesn't work.

CREEATION commented 8 years ago

I can't reproduce the error, everything works fine on my end. Can you setup a simple project where the problem occurs so I can debug?

//e: Try to make ../components/**/*.jade a placeholder (see advanced example in README)

sanjinc commented 8 years ago

@CREEATION thanks for getting in touch, please check: https://github.com/sanjinc/gulp-jade-globbing-test

I tried with a placeholder, and I get the same error - like nothing changed in the pipeline: ENOENT, no such file or directory '/Volumes/HDD/Sites/_test/jadeglobbingtest/templates/{alltemplates}.jade'

CREEATION commented 8 years ago

Wow. Finally, I tracked it down to vinyl-map, see this issue: https://github.com/hughsk/vinyl-map/issues/7.

I updated to vinyl-map2 and am currently working on a patch here: https://github.com/CREEATION/gulp-jade-globbing/tree/vinyl-map-fix

Could you test the vinyl-map-fix branch for me in your real project, not your debug project?

  1. Manually wipe all files inside node_modules/gulp-jade-globbing
  2. Insert the new files from https://github.com/CREEATION/gulp-jade-globbing/archive/vinyl-map-fix.zip
  3. Run npm install in the gulp-jade-globbing directory
  4. Test your gulp task again

This setup works for me now:

project structure

+ gulp-jade-globbing-test-master/
  | gulpfile.js
  | package.json
  + views/
  |   all.jade ....... # without placeholder include
  + templates/
  +   01/
  |   | one.jade
  +   02/
  |   | two.jade
  + pages/ ........... # dist
  |   all.html ....... # if it works :)

views/all.jade

include ../templates/**/*.jade

+first
+second

gulpfile.js

var gulp = require('gulp');
var jade = require('gulp-jade');
var jadeGlobbing = require('gulp-jade-globbing');

// define tasks here
gulp.task('default', function () {

  gulp.src('./views/all.jade')
    .pipe(jadeGlobbing())
    .pipe(jade())
    .pipe(gulp.dest('./pages/'));

});

In your test project, this will include all.jade into all.jade (at least tries), which causes an error.

I guess you can safely delete the test repo now :smiley_cat:

sanjinc commented 8 years ago

@CREEATION thanks for the effort!

This fix works, but only for that test scenario. In my real project I have the same problem when I use asterisks in another file (different than the one which gulp executes). I have setup another test example, more closer to real life project and the one I use - please check these two examples.

This one works: https://github.com/sanjinc/gulp-jade-globbing-test/tree/works

This one doesnt work: https://github.com/sanjinc/gulp-jade-globbing-test/tree/works-not

Notice the difference in jade files inside pages directory.

CREEATION commented 8 years ago

Hello again!

I see the problem here. gulp-jade-globbing doesn't go through all jade files, only those which are passed through to it. As all.jade get's included elsewhere, gulp-jade-globbing doesn't touch the file and therefore the path doesn't get replaced. I'm working on the problem, but didn't make much progress yet. Help is always appreciated :) In the meantime you can use the placeholders as a workaround.

sanjinc commented 8 years ago

Thanks for double checking that.

Yeah, placeholders will do the trick... now if only Jade would allow absolute path :-)

I will see if I can help somehow.