Search code examples
yeomanyeoman-generator

Force overwrite file


I'm using this in my generator

this.fs.copy(this.templatePath('index.html'),this.destinationPath('index.html') );

I want it to skip the overwrite confirmation everytime it finds a confilict (like force overwrite option)


Solution

  • This is not possible. Yeoman will always ask the user for confirmation before overwriting a file. This is a contract the tool takes with its users: it won't overwrite a file without their acknowledgement.

    As a user, if you trust your generator, you can run it with the --force flag to automatically overwrite the conflicting files.