Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy .htaccess (a dotfile) with gulp failed

In a gulp task, I try to copy files in a build folder.

gulp.task( addon, function() {
    var a_addon_function = addon.split("_") ;
    var addon_dirname = a_addon_function[1];
    var dest_path = ( options.env === "tests" || ( options.env === "dist" && options.type === "premium" ) ) ? build_path + addon_dirname + "/" + addon_dirname : build_path + addon_dirname;
    return gulp.src( [ "./plugins/addons/" + addon_dirname + "/**/*", "./plugins/_common/**/*", "./plugins/addons/_common/**/*" ] )
       .pipe( gulp.dest( dest_path ) 
    );
});

The file .htaccess is never copied. Why ? How to resolve this ?

like image 305
J.BizMai Avatar asked Sep 05 '25 20:09

J.BizMai


1 Answers

Dots

If a file or directory path portion has a . as the first character, then it will not match any glob pattern unless that pattern's corresponding path part also has a . as its first character.

For example, the pattern a/.*/c would match the file at a/.b/c. However the pattern a/*/c would not, because * does not start with a dot character. You can make glob treat dots as normal characters by setting dot:true in the options.

Set the option:

gulp.src('...…….', { dot: true }) 

so that the dot is treated like any other character. You should be able to use your original gulp.src then.

From node-glob documentation

like image 113
Mark Avatar answered Sep 09 '25 22:09

Mark