Skip to content

Commit

Permalink
Add replaceInFile for android
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgovea committed Jun 4, 2019
1 parent 00f0100 commit 72f1170
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ern-container-gen-android/src/AndroidGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {

import _ from 'lodash'
import path from 'path'
import fs from 'fs'
import readDir from 'fs-readdir-recursive'

const PATH_TO_TEMPLATES_DIR = path.join(__dirname, 'templates')
Expand Down Expand Up @@ -183,6 +184,20 @@ export default class AndroidGenerator implements ContainerGenerator {
)
}

if (pluginConfig.android.replaceInFile) {
for (const r of pluginConfig.android.replaceInFile) {
const pathToFile = path.join(config.outDir, r.path)
const fileContent = fs.readFileSync(pathToFile, 'utf8')
const patchedFileContent = fileContent.replace(
RegExp(r.string, 'g'),
r.replaceWith
)
fs.writeFileSync(pathToFile, patchedFileContent, {
encoding: 'utf8',
})
}
}

if (pluginConfig.android.dependencies) {
const transitivePrefix = 'transitive:'
const filesPrefix = 'files'
Expand Down

0 comments on commit 72f1170

Please sign in to comment.