gulpjs / glob-stream

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

Gulp.dest fails to move files between filesystems in v5 #127

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.dest copies files between filesystems as it happened in v4.

What actually happened?

No files are copied, but they are present in intermediate directory.

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:12:23] Using gulpfile /code/gulpfile.mjs
[16:12:23] Starting 'build'...
[16:12:23] Starting 'css'...
[16:12:30] Finished 'css' after 7.14 s
[16:12:30] Starting 'hash'...
[16:12:39] Finished 'hash' after 8.38 s
[16:12:39] Finished 'build' after 16 s
Done in 16.90s.
vagrant@debian11:/code$ ls -l /tmp/gulp-build-cache/
total 4
drwxr-xr-x 6 vagrant vagrant 4096 Apr  6 16:11 css
vagrant@debian11:/code$ ls -l public/static
total 0

Please provide the following information:

Additional information

Changing tmp: path.join(os.tmpdir(), 'gulp-build-cache'), to tmp: 'assets/build', results in working script and files are properly copied from intermediate directory to final one. /tmp and the /code (cwd in which gulp is executed) are on different filesystems.

vagrant@debian11:/code$ sed -i "s#path.join(os.tmpdir(), 'gulp-build-cache')#'assets/build'#g" gulpfile.mjs
vagrant@debian11:/code$ yarn gulp build
yarn run v1.22.22
$ node ./node_modules/gulp/bin/gulp.js build
[16:25:10] Using gulpfile /code/gulpfile.mjs
[16:25:10] Starting 'build'...
[16:25:10] Starting 'css'...
[16:25:14] Finished 'css' after 4.95 s
[16:25:14] Starting 'hash'...
[16:25:21] Finished 'hash' after 6.64 s
[16:25:21] Finished 'build' after 12 s
Done in 13.18s.
vagrant@debian11:/code$ ls -l assets/build
total 4
drwxrwxr-x 1 vagrant www-data 4096 Apr  6 16:25 css
vagrant@debian11:/code$ ls -l public/static
total 4
drwxrwxr-x 1 vagrant www-data 4096 Apr  6 16:24 css
yocontra commented 7 months ago

This is due to an issue with glob-stream not resolving absolute paths that was just introduced, will transfer this issue over there.

As a workaround, you can avoid using absolute paths in gulp.src