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

gulp.src doesn't match wildcard #1412

Closed
190n opened this issue Nov 25, 2015 · 2 comments
Closed

gulp.src doesn't match wildcard #1412

190n opened this issue Nov 25, 2015 · 2 comments

Comments

@190n
Copy link

190n commented Nov 25, 2015

gulp.src is only matching three files in a glob.

gulpfile.js:

var gulp = require('gulp'),
    babel = require('gulp-babel'),
    browserify = require('browserify'),
    source = require('vinyl-source-stream');

gulp.task('default', function() {
    gulp.src('./lib/*.js')
        .pipe(babel())
        .pipe(gulp.dest('build/'));
    return browserify('build/main.js')
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('build/'));
});

Files in lib: base-entity.js compound-entity.js constants.js image-entity.js invader.js invader-manager.js main.js manager.js movement.js tank.js text-entity.js

Running gulp:

[14:10:35] Using gulpfile ~/code/js/nueva-my-page/gulpfile.js
[14:10:35] Starting 'default'...
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module '/home/ben/code/js/nueva-my-page/build/main.js' from '/home/ben/code/js/nueva-my-page'
    at /home/ben/code/js/nueva-my-page/node_modules/resolve/lib/async.js:55:21
    at load (/home/ben/code/js/nueva-my-page/node_modules/resolve/lib/async.js:69:43)
    at onex (/home/ben/code/js/nueva-my-page/node_modules/resolve/lib/async.js:92:31)
    at /home/ben/code/js/nueva-my-page/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

Files in build after that: base-entity.js compound-entity.js constants.js

If I pass in an array of all the files, it still doesn't work. But it does work if I do it for each file individually.

@doowb
Copy link
Member

doowb commented Nov 25, 2015

The browserify('build/main.js') piece is going to start immediately, so the first statement might be finished writing the files to build/.

Try splitting this into 2 tasks and making one a dependency of the other...

var gulp = require('gulp'),
    babel = require('gulp-babel'),
    browserify = require('browserify'),
    source = require('vinyl-source-stream');

gulp.task('build', function() {
  return gulp.src('./lib/*.js')
    .pipe(babel())
    .pipe(gulp.dest('build/'));
});

gulp.task('bundle', ['build'], function() {
  return browserify('build/main.js')
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('build/'));
});

gulp.task('default', ['bundle']);

@190n
Copy link
Author

190n commented Nov 26, 2015

Okay. Thanks!

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

2 participants