gulpjs / glob-stream

Readable streamx interface over anymatch.
MIT License
178 stars 51 forks source link

Gulp.src glob pattern fails in various edge situations #128

Closed proton-ab closed 7 months ago

proton-ab commented 7 months ago

Before you open this issue, please complete the following tasks:

What were you expecting to happen?

Gulp.src works as it did previously in v4, ignoring directories and files outside of scope of patterns provided. No error is raised.

What actually happened?

Gulp.src scans entire directory tree and fails on at least these cases:

Please give us a sample of your gulpfile

import path from 'path';
import os from 'os';

// Gulp specific
import Gulp from 'gulp';

const dirs = {
  tmp: path.join(os.tmpdir(), 'gulp-build-cache'),
  out: 'public/static',
};

// ---

function hash() {
  return Gulp.src(`${dirs.tmp}/**/*.*`)
    .pipe(Gulp.dest(dirs.out))
}

// ---

function css() {
  return Gulp.src('assets/public/**/*.css')
    .pipe(Gulp.dest(dirs.tmp));
}

// ---

export const build = Gulp.series(css, hash);

Terminal output / screenshots

vagrant@debian11:/code$ yarn gulp build
yarn run v1.22.22
$ node ./node_modules/gulp/bin/gulp.js build
[16:26:34] Using gulpfile /code/gulpfile.mjs
[16:26:34] Starting 'build'...
[16:26:34] Starting 'css'...
[16:26:40] Finished 'css' after 6.07 s
[16:26:40] Starting 'hash'...
[16:26:42] 'hash' errored after 2.12 s
[16:26:42] Error: ENOENT: no such file or directory, scandir '/code/vendor/dflydev/fig-cookies'
[16:26:42] 'build' errored after 8.2 s
vagrant@debian11:/code$ yarn gulp build
yarn run v1.22.22
$ node ./node_modules/gulp/bin/gulp.js build
[16:31:32] Using gulpfile /code/gulpfile.mjs
[16:31:32] Starting 'build'...
[16:31:32] Starting 'css'...
[16:31:32] 'css' errored after 20 ms
[16:31:32] Error: ENOENT: no such file or directory, stat '/code/scripts'
[16:31:32] 'build' errored after 23 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
vagrant@debian11:/code$ ls -l /code/scripts
lrwxrwxr-x 1 vagrant www-data 0 Oct 29  2021 /code/scripts -> ../calamari/scripts

Please provide the following information:

Additional information

The first terminal output is result of running composer in parallel with gulp. Second one is result of placing broken link in directory tree (the link becomes valid later on, but is not at the time gulp is being run). The issue seems related to https://github.com/gulpjs/glob-stream/issues/129 but is different enough that I believe it warrants raising separate issue.

phated commented 7 months ago

@proton-ab can you try out 8.0.2 and open more concise issues for anything that still has problems? Thanks 🙏

proton-ab commented 7 months ago

Will try in a moment and report back.

I still need to look into https://github.com/gulpjs/glob-stream/issues/128 because the issue isn't clear on what paths don't work, as the only error seems to indicate an absolute path outside of the cwd.

Sorry, I had to redact path in the first error message and might've caused confusion. I've adjusted it to be a absolute path as that seems to be what error message always produces. cwd of gulp in this case is /code. Assuming that you no longer walk entire cwd tree then this should be resolved as Gulpfile only globs on /code/assets/**.

proton-ab commented 7 months ago

Can confirm v8.0.2 is not susceptible to any of the two edge cases from the issue. Thank you for quick fix.