Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Update: replace sed command to plain js / fixed android path camelcas…
Browse files Browse the repository at this point in the history
…e bug (#69)
  • Loading branch information
leonskim authored Aug 1, 2018
1 parent 1e69d99 commit 8028655
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions boilerplate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { merge, pipe, assoc, omit, __ } = require('ramda')
const { getReactNativeVersion } = require('./lib/react-native-version')
const os = require('os')

/**
* Is Android installed?
Expand Down Expand Up @@ -172,10 +171,15 @@ async function install (context) {
spinner.text = `▸ setting up splash screen`
spinner.start()
spinner.text = `▸ setting up splash screen: configuring`
const backupExtension = (os.platform() === 'darwin') ? '""' : ''
await system.run(`sed -i ${backupExtension} 's/SplashScreenPatch/${name}/g' ${process.cwd()}/patches/splash-screen/splash-screen.patch`, { stdio: 'ignore' })
const patchPath = `${process.cwd()}/patches/splash-screen/splash-screen.patch`
const patch = filesystem.read(patchPath)
const androidOldMainPathRegex = new RegExp('/android/app/src/main/java/com/SplashScreenPatch/MainActivity.java', 'g')
const androidNewMainPath = `/android/app/src/main/java/com/${name.toLowerCase()}/MainActivity.java`
const androidPatch = patch.replace(androidOldMainPathRegex, androidNewMainPath)
const patchForNewProject = androidPatch.replace(/SplashScreenPatch/g, name)
filesystem.write(patchPath, patchForNewProject)
spinner.text = `▸ setting up splash screen: cleaning`
await system.run(`git apply ${process.cwd()}/patches/splash-screen/splash-screen.patch`, { stdio: 'ignore' })
await system.run(`git apply ${patchPath}`, { stdio: 'ignore' })
filesystem.remove(`${process.cwd()}/patches/splash-screen`)
}
await patchSplashScreen()
Expand Down

0 comments on commit 8028655

Please sign in to comment.