Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for me #8

Open
lordgreg opened this issue Sep 8, 2015 · 10 comments
Open

Not working for me #8

lordgreg opened this issue Sep 8, 2015 · 10 comments

Comments

@lordgreg
Copy link

lordgreg commented Sep 8, 2015

Hi,

I've tried to run the code posted, like this:

  var ghtmlSrc = require('gulp-html-src');
  gulp.src('www/index.html')
      .pipe(ghtmlSrc())
      .pipe(gulp.dest('./wwwtest/'));

And this isn't working. Part of my html looks like this:

    ...
    <!-- build:js scripts/vendor.js -->
    <!-- bower:js -->
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-animate/angular-animate.js"></script>
    <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
    <script src="bower_components/ionic/release/js/ionic.js"></script>
    <script src="bower_components/ionic/release/js/ionic-angular.js"></script>
    <script src="bower_components/ngCordova/dist/ng-cordova.js"></script>
    <script src="bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js"></script>
    <script src="bower_components/angular-translate/angular-translate.js"></script>
    <script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
    <script src="bower_components/localforage/dist/localforage.js"></script>
    ...

So, what am I actually doing wrong?

@bruderstein
Copy link
Owner

It sounds like it can't find the files. I'm guessing it can't find www/bower_components/angular/...., or maybe it's forgetting the www/ and your bower_components directory is in the www directory.

I'll try and check later how it deals with this - in the meantime, can you post where your bower_components is in relation to the www?

@lordgreg
Copy link
Author

lordgreg commented Sep 9, 2015

Hi and thank you for replying @bruderstein. You're right. Everything is packed in www directory. So the bower_components/ is subdirectory of www/, which means: www/bower_components/ is where our js libraries are.

@bruderstein
Copy link
Owner

Ok, I've tried this exact layout out, and it works fine for me.

+ --- gulpfile.js
+---  www
      +--- index.html
      +--- bower_components
             +---- angular
                     +---- angular.js
                     +---- ... etc

Can you try adding a gulp-debug line before and after the ghtmlSrc(), and paste the output here.
e.g.

var debug = require('gulp-debug');
var ghtmlSrc = require('gulp-html-src');

 gulp.task('default', function () {
    return gulp.src('www/index.html')
        .pipe(debug({ title: 'before'}))
        .pipe(ghtmlSrc())
        .pipe(debug({ title: 'after' }))
        .pipe(gulp.dest('dist'));
});

For my little page, I get the following output:

[20:18:37] Using gulpfile ~/gulp-html-src-test/gulpfile.js
[20:18:37] Starting 'default'...
[20:18:37] before www/index.html
[20:18:37] before 1 items
[20:18:38] after www/js/test1/test.js
[20:18:38] after www/js/test2/test.js
[20:18:38] after 2 items
[20:18:38] Finished 'default' after 44 ms

@lordgreg
Copy link
Author

Hi. Thank you for replying. Can you also post the index.html code if possible? Thank you.

@bruderstein
Copy link
Owner

Nothing to it, but all based under the www directory:

<body>
<script src="js/test1/test.js"></script>
<script src="js/test2/test.js"></script>
</body>

@jwneedls
Copy link

jwneedls commented May 6, 2016

I'm getting a similar issue. Set up a very simple test structure.

gulpfile.js

var gulp = require('gulp');
var ghtmlSrc = require('gulp-html-src');

gulp.task('abc', function () {
   return gulp.src('src/*.html')
      .pipe(debug({ title: 'before'}))
      .pipe(ghtmlSrc())
      .pipe(debug({ title: 'after' }))

src/test.html

<html>
        <head>
                <script src="testscript.js"></script>
        </head>
       <body>
                <script src="testscript2.js"></script>
        </body>
</html>

My output is as follows:

[08:25:13] Using gulpfile /var/www/html/gulpfile.js
[08:25:13] Starting 'abc'...
[08:25:13] before src/test.html
[08:25:14] before 1 items

Then nothing.
I ran the tests in the gulp-html-src directory, by doing an 'npm test' and got two errors:

 15 passing (815ms)
 2 failing

  1) gulp-html-src for streams emits single script stream from html:
     Uncaught TypeError: Cannot read property 'length' of null
      at Function.Buffer.concat (buffer.js:219:24)
      at PassThrough.<anonymous> (test/test.js:447:29)
      at endReadableNT (_stream_readable.js:913:12)

  2) gulp-html-src for streams emits multiple script streams from html:
     Uncaught TypeError: Cannot read property 'length' of null
      at Function.Buffer.concat (buffer.js:219:24)
      at PassThrough.<anonymous> (test/test.js:447:29)
      at endReadableNT (_stream_readable.js:913:12)

Node version v4.4.4, NPM version 2.15.1, Gulp 3.9.1. Running this on CentOS 7. Happy to provide any further information for debugging... hoping I've just done something stupid here?

@dceejay
Copy link

dceejay commented May 12, 2016

Also now hitting this - similar simple setup
Node 4.4.4, npm 2.15.1, gulp 3.9.1 - on MacOS and Ubuntu 14.04 LTS

@bruderstein
Copy link
Owner

This should be pretty easy to fix - I'm away for a few days though - I'll take a look next week.

@TCB13
Copy link

TCB13 commented Oct 2, 2016

Same issue around here. @bruderstein any news on this?

@felipe-augusto
Copy link

felipe-augusto commented Jan 30, 2017

If you go to line 121 from the index.js file and replace this:

callback();

By this:

setTimeout(function () {callback();}, 0);

It passes all the tests, but still does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants