Gulp stream error when using wildcard for containing directory?
<p>I have a Gulp task...</p>

<pre><code>gulp.task('compileJS', function () {
    var jsStream = gulp.src(['resources/js/app.js', 'resources/js/assets/**/*.js']);
    jsStream.pipe(concat('all.js'))
    .pipe(uglify())
    .on('error', gutil.log)
    .pipe(gulp.dest('resources/js'));
});
</code></pre>

<p>It renders this error when I try and run it...</p>

<pre><code>{ [Error: /home/allen/Projects/WWW/SunHorizonEnergy/resources/js/all.js: 'return' outside of function]
  message: '/home/allen/Projects/WWW/SunHorizonEnergy/resources/js/all.js: \'return\' outside of function',
  fileName: '/home/allen/Projects/WWW/SunHorizonEnergy/resources/js/all.js',
  lineNumber: 161750,
  stack: 'Error\n    at new JS_Parse_Error (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/node_modules/gulp
-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:1526:18)\n    at js_error (eval at &lt;anonymous&gt; (/home/allen/
Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:1534:11)\n
 at croak (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/uglify-js/to
ols/node.js:22:1), &lt;anonymous&gt;:2026:9)\n    at eval (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/node_mod
ules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:2168:21)\n    at eval (eval at &lt;anonymous&gt; (/home/a
llen/Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:2073:24)
\n    at block_ (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/uglify

-js/tools/node.js:22:1), &lt;anonymous&gt;:2353:20)\n    at eval (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/n
ode_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:2120:29)\n    at eval (eval at &lt;anonymous&gt; (
/home/allen/Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:2
073:24)\n    at if_ (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEnergy/node_modules/gulp-uglify/node_modules/ug
lify-js/tools/node.js:22:1), &lt;anonymous&gt;:2336:44)\n    at eval (eval at &lt;anonymous&gt; (/home/allen/Projects/WWW/SunHorizonEner
gy/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:22:1), &lt;anonymous&gt;:2164:24)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-uglify' }
</code></pre>

<p>But, it works completely fine if I specify the directory names instead of using the <code>**</code> wildcard. I could definitely do that, but it kind of detracts from the scalability of my application...which is one of the main reasons I use a task runner in the first place.</p>

<p>Even stranger, I have another task that does almost the exact same thing, but for SCSS and CSS files...</p>

<pre><code>gulp.task('compileCSS', function () {
    var cssStream = gulp.src('resources/styles/CSS/**/*.css');
    var scssStream = gulp.src('resources/styles/SCSS/main.scss')
    .pipe(sass())
    .on('error', sass.logError);
    eventStream.concat(cssStream, scssStream)
    .pipe(concat('main.css'))
    .pipe(cleanCSS())
    .pipe(gulp.dest('resources/styles'));
});
</code></pre>

<p>This works just fine! And I'm using the <code>**</code> wildcard! I have confirmed that the directory is correct by manually replacing <code>**</code> with a directory.</p>

<p>What gives?</p>