Tag: grunt contrib copy

从一个特定的文件夹复制另一个文件夹中的文件

我有以下目录树: – client – plugins – plugin1 – plugin2 – plugin3 – widgets – widget1 – widget2 – resources – img 我需要从属于任何特定的插件小部件资源的所有文件复制到一个文件夹使用grunt副本,所以我使用下面的globbing模式来查找这些文件: src: 'client/plugins/**/*/resources/img/*' 但似乎无法find它们,所以我猜这种模式是错误的。 我的错误在哪里?

grunt-contrib-copy死于EPERM操作不允许“C:\ Documents and Settings”

我正在尝试使用grunt-contrib-copy来运行一个简单的grunt任务,但它在到达复制任务时立即死亡,并带有以下消息: 运行“复制:主”(复制)任务 警告:EPERM,不允许操作'C:\ Documents and Settings'使用 – 强制继续 由于警告而中止 我在跑步: Windows 7 64位(所以C:\Documents and Settings不存在) 节点0.10.28(安装在C:\nodejs ) npm 1.4.9 grunt-cli 0.1.13 咕噜0.4.5 grunt-contrib-copy 0.5.0 我已经在C:\nodejs和我的项目文件夹( C:\Users\myusername\Documents\Programming\myprojectname ,在那里没有空格或圆括号)上对“Documents and Settings”进行了全文search,但没有任何匹配。 我的copy任务定义是: copy: { main: { files: [ {expand: true, cwd: 'src/core', src: '/**', dest: 'src/chrome/'}, {expand: true, cwd: 'src/core', src: '/**', dest: 'src/firefox/'} ] } }, […]

检查目标文件是否已经存在

目标 要检查两个文件夹(src和目标文件夹)中是否存在具有相同名称的文件, 尝试尝试使用grunt-contrib-copy来遍历path,但显然这是行不通的。 copy: { unit: { expand: true, cwd: 'src', src: '**', dest: 'specs/unit', filter: function(filepath){ if(grunt.file.exists(filepath)){ return grunt.file.write(filepath,''); } } } }, 我的理论 grunt.file.exists似乎指向src文件夹而不是目标文件夹。 因此,它不会检查src文件夹中的文件是否确实存在于目标文件夹中,它只是检查src文件夹中是否有任何文件。

Grunt – 你可以从一个自定义的注册任务中调用grunt-contrib-copy,并自定义副本吗?

我知道我可以在grunt.config中设置一个任务grunt-contrib-copy从src到dest的文件,并通过Grunt文档查看我知道我可以使用grunt.file.copy复制单个文件。 但是,是否可以在自定义注册任务中dynamic创buildgrunt-contrib-copy任务,以容纳从bash发送的参数? 我想创build一个新目录grunt.file.mkdir(“some / path / appfoldername”),然后将文件从另一个目标文件复制到该文件夹​​,但直到运行自定义任务后,我才知道文件夹名称。 所以像这样: grunt create_app:appfoldername 所以我可以一次复制一个文件,但是文件会改变,所以需要grunt-contrib-copy的强大function,但是可以自定义注册任务的灵活性。 如果我的解释不够清楚,我想像这样: grunt.registerTask('createCopy', 'Create a copy', function(folderName) { var cwd = grunt.template.process("some/path/to/app"); var src = grunt.template.process("some/path/to/src"); var dest = grunt.template.process("some/path/to/dest") + folderName; grunt.task.run('copy: { files: { cwd: cwd, src: src, dest: dest } }'); } UPDATE grunt.registerTask('mkapp', 'Create Application', function(appName) { // Check appName is […]