Grunt重命名不起作用 [英] Grunt rename not working

查看:159
本文介绍了Grunt重命名不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录结构如下所示:

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

我的gruntfile包含以下任务:

 复制:{
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%>,

当我运行复制任务时,它将所有选定的文件复制到包含软件包名称,版本和生成日期的目录中,但它会复制整个src目录。而我只想复制src目录的内容,所以我试图使用 rename`属性从dest中删除 src /',该属性不起作用一些原因。

我今天才开始使用grunt,所以我可能会在这里冒出一个菜鸟错误。

cwd (当前工作目录)选项。除非您实际上想将文件压缩到单个目录中。

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


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/"
    }
}

这篇关于Grunt重命名不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆