Вопрос

My directory structure looks like this:

-src/
-----pages/
----------...
-----...
-build

My gruntfile contains the following task:

copy: {
    all:{
        dest:"<%= builddir %>/",
        src: ["src/**/*.{yaml,yml,py,html,htm,json,css}"],
        rename:function(d, s){return d.replace("src/","");}
    }
},
builddir: "build/<%= pkg.name %>-<%= pkg.version %>-<%= date %>",

When I run the copy task, it copies all the selected files into the directory containing the package name, version and build date, as expected, but it copies the entire src directory. while I only want to copy the contents of the src directory, so I'm trying to remove src/' from dest using therename`property, which doesn't work for some reason.

I've only started using grunt today, so I might be makiing a rookie mistake here.

Это было полезно?

Решение

Hmm... I think all you need is the cwd (current working directory) option. Unless you in fact want to flatten the files into a single directory.

copy: {
    all:{
        expand: true,
        dest:"<%= builddir %>/",
        src: ["**/*.{yaml,yml,py,html,htm,json,css}"],
        cwd: "src/"
    }
}

Другие советы

You'll need to set the flatten option, which removes the directory structure.

copy: {
    all:{
        expand: true,
        flatten: true,
        dest:"<%= builddir %>/",
        src: ["src/**/*.{yaml,yml,py,html,htm,json,css}"]
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top