简体   繁体   中英

Copy all files except .map files in nodejs

I'm using the ncp plugin to copy files in nodejs, and in the option filter is described as following:

options.filter - a RegExp instance, against which each file name is tested to determine whether to copy it or not, or a function taking single parameter: copied file name, returning true or false, determining whether to copy file or not.

But when I add a filter on .map files (since I want to copy everything except .map files) nothing is copied, and here is my code:

ncp(path.join(distPath, asset), path.join(exportPath, exportFolderName, asset), {
        clobber: false,
        filter: /\.(map)$/,
      });

How can I solve this?

You could try turning the filter into a function.

ncp(path.join(distPath, asset), path.join(exportPath, exportFolderName, asset), {
    clobber: false,
        filter: function (f) {
            f.endsWith(".map");
        },
    }
);

It was working here https://github.com/AvianFlu/ncp/issues/125

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM