Skip to content

Commit

Permalink
fix: don't render .ejs files in a migration operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Aug 27, 2019
1 parent d573995 commit 1619ffd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ module.exports = class MigrationOperationAPI {
return filename
}).join('/')
const sourcePath = path.resolve(source, rawPath)
const content = renderFile(sourcePath, data, ejsOptions)
let content
if (path.extname(sourcePath) !== '.ejs') {
content = renderFile(sourcePath, data, ejsOptions)
} else {
content = fs.readFileSync(sourcePath, { encoding: 'utf8' })
}
// only set file if it's not all whitespace, or is a Buffer (binary files)
if (Buffer.isBuffer(content) || /[^\s]/.test(content)) {
this.migrationOperation.writeFile(targetPath, content, files)
Expand Down

0 comments on commit 1619ffd

Please sign in to comment.