0

I need to replace a Text in a directory tree and copy to another folder. I'm using grunt text-replace plugin and Glob npm. you could see the config next:

replace: {
    replace2: {
        src: 'js/app/circo/**/*.js',
        dest: 'js/app/circo2/',
        replacements: [{
            from: 'app/payasos',              
            to: 'app/funambulistas'
            }
        ]
    }
},

This settings replace the text and copy all the file into the js/app/circo2/ folder and the tree disappear.

I try to change the dest to:

dest: 'js/app/circo2/**',

but this show this error:

Running "replace:replace2" (replace) task Warning: Unable to read "js/app/circo/" file (Error code: EISDIR). Use --force to continue.

Thanks.

Sonny Chivas
  • 17
  • 10

1 Answers1

0

Well, I finally use two Grunt plugin: copy and replace. that the configuration:

copy: {
    main: {
        files: [
            {expand: true,  cwd: 'js/app/circo/',src: '**', dest: 'js/app/circo2/'}
        ]
    }

},

replace: {
    replace2: {     
        src: 'js/app/circo2/**/*.js',
        overwrite:true,
        replacements: [{
            from: 'app/payasos',              
            to: 'app/funambulistas'
            }
        ]
    }
}

First copy the file making all src relative to cwd. You can see the setting here .

Secondly, I replace from 'app/payasos' to 'app/funambulistas' in the js/app/circo2//*.js** src (all js files in directory and sub-directories inside circo2 folder). on both configurations is used the "globstar". You can see more info about glob here.

That work for me but I'm sure that it possible do it using replace.

Sonny Chivas
  • 17
  • 10