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

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

Open
ghnp5 opened this issue Aug 16, 2024 · 1 comment
Open

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

ghnp5 opened this issue Aug 16, 2024 · 1 comment

Comments

@ghnp5
Copy link

ghnp5 commented Aug 16, 2024

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
Copy link
Author

ghnp5 commented Sep 20, 2024

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.

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

1 participant