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

gulp.dest() wrong path if foldername contains "*" #2750

Closed
happen-studio opened this issue Jan 18, 2024 · 6 comments
Closed

gulp.dest() wrong path if foldername contains "*" #2750

happen-studio opened this issue Jan 18, 2024 · 6 comments

Comments

@happen-studio
Copy link

If the name of the folder contains the character "*", then gulp.dest() does not work properly.
In my example, gulp saves the css file in:

*workspaces / project01 / css / *workspaces / project01 / css /

my folder structure:

+ *workspaces
           + project01 (gulp folder)
                 + _build
                 + css 

my code:

…
function styles(done) {
    gulp.src('_build/css/*.css')
			         .pipe(plumber())
			         .pipe(gcmq())
			         .pipe(csso())
			         .pipe(plumber())
			         .pipe(gulp.dest('css/'))
.pipe(browserSync.stream({match: '**/*.css'}));
done();
}
…
  • OSX version 13.2.1
  • node version 19.3.0
  • npm version 9.8.1
  • gulp version (CLI 2.3.0, local 4.0.2)
@peteichuk
Copy link

I have this problem too. I did not change versions in package.json, but some updates in gulp destroyed my project.

@yocontra
Copy link
Member

yocontra commented Apr 6, 2024

This should be fixed in gulp 5

@yocontra yocontra closed this as completed Apr 6, 2024
@peteichuk

This comment has been minimized.

@peteichuk
Copy link

This should be fixed in gulp 5
Hello, I migrated my project to Gulp 5 today, but the problem is still for me.

@yocontra
Copy link
Member

@peteichuk Can you post some code that demonstrates your issue?

@peteichuk
Copy link

peteichuk commented May 20, 2024

@peteichuk Can you post some code that demonstrates your issue?

Hello, sure. This is a simple code, but the project is very large and uses multiple configurations in a foreach loop, pushing other tasks. However, there's an issue with excluding "dest" files, which results in having bad images (this images not opening) at their original size and some problematic JS files. I don't understand where the problem lies—whether it's with the mapping in the template string src ('apps/_shared/libs/*') or memory for Node.js. But ever since I started creating new builds after 2023, I've been experiencing this issue, even though I haven't made any updates to the config or the project.

Code:

const gulp = require('gulp'),
    minify = require('gulp-minify'),
    sass = require('gulp-sass'),
    cssmin = require('gulp-cssnano'),
    prefix = require('gulp-autoprefixer'),
    buble = require('gulp-buble');

const tasks = [];

function addToTaskSharedDir() {
    let task = 'copyLibs-shared';
    tasks.push(task);

    gulp.task(task, function () {
        return gulp.src('apps/_shared/libs/*')
          .pipe(gulp.dest('public/shared/libs'));
    });

    task = 'copyImages-shared';
    tasks.push(task);

    gulp.task(task, function () {
        return gulp.src('apps/_shared/images/**/*')
          .pipe(gulp.dest('public/shared/images'));
    });

    task = 'buildJS-shared';
    tasks.push(task);

    gulp.task(task, function () {
        return gulp.src(['apps/_shared/javascripts/*.js'])
          .pipe(buble())
          .pipe(minify())
          .pipe(gulp.dest('public/shared/js'))
    });

    task = 'buildCSS-shared';
    tasks.push(task);

    gulp.task(task, function () {
        return gulp.src(['apps/_shared/scss/*.scss'])
          .pipe(sass())
          .pipe(prefix({
              overrideBrowserslist: ['last 2 versions'],
              cascade: false
          }))
          .pipe(cssmin())
          .pipe(gulp.dest('public/shared/css'));
    });
}

addToTaskSharedDir();

gulp.task('build', gulp.series(tasks));

and the second problem shows it's Error: ENOENT: no such file or directory, scandir, in 2023 it worked, but today not work. The problem with ignoring not existing directory is when we use the symbol * in the src string, so to fix it I added some if statements for check before pushing this task for gulp tasks in an array.

Thanks!

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

3 participants