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

Commit

Permalink
fix(windows): Move postInstall commands to their own script; add comm…
Browse files Browse the repository at this point in the history
…and to kill metro (#247 by @bryanstearns)
  • Loading branch information
bryanstearns authored and jamonholmgren committed Sep 16, 2019
1 parent 2de73cd commit d5e878d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion boilerplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async function install(context) {
template: "app/screens/demo-screen/demo-screen.tsx.ejs",
target: "app/screens/demo-screen/demo-screen.tsx",
},
{ template: "bin/postInstall", target: "bin/postInstall" },
]
const templateProps = {
name,
Expand Down Expand Up @@ -255,7 +256,7 @@ async function install(context) {

ignite.patchInFile(`${process.cwd()}/package.json`, {
replace: `"postinstall": "solidarity",`,
insert: `"postinstall": "solidarity && jetify && if which pod >/dev/null; then (cd ios; pod install); fi",`,
insert: `"postinstall": "./bin/postInstall",`,
})
} catch (e) {
ignite.log(e)
Expand Down
37 changes: 37 additions & 0 deletions boilerplate/bin/postInstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env node

const childProcess = require("child_process")
const os = require("os")

/**
* Do all things that need to be done after installing packages
*
* Yes, it slows down package installation a little, but it's nice to not
* have to remember these extra steps.
*/
;[
// Make sure we're set up correctly
{ command: "solidarity" },

// Kill the metro bundler if it's running.
{ command: 'pkill -f "cli.js start" || set exit 0', onlyPlatforms: ["darwin", "linux"] },
// Help wanted: Add the windows version here. { command: "????", onlyPlatforms: ["win32"] },

// Make sure our native modules are androidX-happy
{ command: "jetify" },

// on iOS, make sure our native modules are installed
{ command: "pod install", cwd: "ios", onlyPlatforms: ["darwin"] },
]
.filter(({ onlyPlatforms }) => !onlyPlatforms || onlyPlatforms.includes(os.platform()))
.forEach(commandAndOptions => {
const { command, onlyPlatform: _, ...options } = commandAndOptions
try {
childProcess.execSync(command, {
stdio: "inherit",
...options,
})
} catch (error) {
process.exit(error.status)
}
})

0 comments on commit d5e878d

Please sign in to comment.