glob-stream icon indicating copy to clipboard operation
glob-stream copied to clipboard

Only some files are being copied, if run inside a series

Open ghnp5 opened this issue 1 year ago • 1 comments

What were you expecting to happen?

All 840 files should be copied, recursively.

What actually happened?

Only the first few files (sorted alphabetically) of each folder are being copied, instead of all files.

This used to work, but seems broken since v5.

This is happening as the last step of a gulp.series, consistently. But if I run npx gulp copy-changed, it copies all the files, always.

Please give us a sample of your gulpfile

import { spawnSync } from 'child_process';
import glob from 'glob';
import path from 'path';
import fs from 'fs';
import mergeStream from 'ordered-read-streams';
import PluginError from 'plugin-error';
import gulp from 'gulp';
import htmlmin from 'gulp-htmlmin';
import clean from 'gulp-clean';
import newer from 'gulp-newer';
import changed from 'gulp-changed';
import rename from 'gulp-rename';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('__filename:', __filename);
console.log('__dirname:', __dirname);

(...)

// npx gulp copy-changed
gulp.task('copy-changed', () => {
	return gulp.src([path.join(__dirname, 'build\\_delta\\**\\*')], { dot: true })
		.pipe(gulp.dest(path.join(__dirname, 'build\\')));
});

gulp.task('build-debug', gulp.series(
	...,
	...,
	...,
	'copy-changed'
));

Terminal output / screenshots

[01:29:42] Using gulpfile F:...\gulpfile.mjs [01:29:42] Starting 'build-debug'... [01:29:42] Starting '...'... [01:29:42] Finished '...' after 209 ms [01:29:42] Starting '...'... [01:29:42] Finished '...' after 107 ms [01:29:42] Starting '...'... (node:20356) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated. (Use node --trace-deprecation ... to show where the warning was created) [01:29:42] Finished '...' after 82 ms [01:29:42] Starting 'copy-changed'... [01:29:43] Finished 'copy-changed' after 1.1 s [01:29:43] Finished 'build-debug' after 1.54 s

Please provide the following information:

  • OS & version: Windows 11
  • node version (run node -v): v22.3.0
  • npm version (run npm -v): 10.8.2
  • gulp version (run gulp -v): CLI version: 3.0.0 Local version: 5.0.0

ghnp5 avatar Aug 16 '24 00:08 ghnp5

The previous task copies stuff to that "_delta" folder, inside a mergeStream (which used to be on merge-stream, but when I was trying to fix this issue, I had upgraded to ordered-read-streams, but the same happens).

Seems that what's happening is that at the time "copy-changed" runs, the files aren't ready yet or so.

If I put a "sleep" of 3 seconds, it seems to work now.

const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

gulp.task('copy-changed', () => {
	return sleep(3000).then(() => {
		return gulp.src([path.join(__dirname, 'build\\_delta\\**\\*')], { dot: true })
		.pipe(gulp.dest(path.join(__dirname, 'build\\')));
	});
});

This used to work before, so I'm not sure why it needs a sleep now.

ghnp5 avatar Sep 20 '24 19:09 ghnp5

Please try v8.0.3 - I believe this is the same problem as #135 but you are in the best position to test it out.

If I don't here back in a little while, I will close this as a duplicate of #135

phated avatar Jun 01 '25 05:06 phated

Thanks very much. I've since moved to another solution since I couldn't keep the instability of Gulp (sorry about that!).

If no one else is complaining, or this is a duplicate, then I'm happy to close this issue.

Thanks for looking and for fixing! 👌🏻

ghnp5 avatar Jun 01 '25 10:06 ghnp5

I've since moved to another solution since I couldn't keep the instability of Gulp (sorry about that!).

It's no problem. Gulp v4 has been stable for almost 10 years and v5 was an explicit departure from some of the norms and expectations.

phated avatar Jun 01 '25 18:06 phated