17

Im using yeoman for a project.

Basically it's working fine, but during the build process I want to move my images folder to somewhere else.

So I loaded the grunt-contrib-copy task which would let me do that. But unfortunately this conflicts with the yeoman built-in copy task.

Is there any way to alias the grunt-contrib-copy in my Gruntfile.js so I can use both of them?

grunt.loadNpmTasks('grunt-contrib-copy');

//Here I need to use "copy" again but not referencing the yeoman task but the grunt-contrib-copy task.
grunt.registerTask('build','intro clean coffee compass mkdirs concat css min replace copy time');

1 Answer 1

33

grunt.renameTask() will probably help you here. Try this:

// temporarily rename yeoman's copy task
grunt.renameTask('copy', 'yeomanCopy');
// load 'copy' from grunt-contrib-copy
grunt.loadNpmTasks('grunt-contrib-copy');
// rename it to something other than 'copy'
grunt.renameTask('copy', 'myCopy');
// rename yeoman's task back to its original name so nothing breaks
grunt.renameTask('yeomanCopy', 'copy');

// now use 'myCopy' for your purposes
// ...
3
  • 1
    Thanks, that works! Though I have the problem that some tasks check if a certain task has been executed before and don't know about their renaming :-/
    – acme
    Dec 18, 2012 at 10:33
  • 1
    But you are renaming the existing yeoman's task back right away, aren't you? Dec 19, 2012 at 15:39
  • 1
    Oops, I stopped at renaming the original task, of course you are right. Thank you Dmitry!
    – acme
    Dec 20, 2012 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.