Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
atlj committed Nov 15, 2024
1 parent 774fd98 commit 5840521
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions packages/react-native-builder-bob/src/utils/runRNCCli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { type SpawnOptions } from 'node:child_process';
import { spawn } from './spawn';
import path from 'node:path';

const RNC_CLI_BINARY_PATH = path.resolve(
process.cwd(), // We are always expected to run in the library
'node_modules',
'.bin',
'rnc-cli'
);
import fs from 'fs-extra'

Check failure on line 4 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`
import assert from 'node:assert'

Check failure on line 5 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`

// This is a special case for calling bob from the XCode scripts
// XCode scripts don't have the node binary properly set
Expand All @@ -23,5 +18,27 @@ export async function runRNCCli(
stdio: 'ignore',
}
) {
const rncCliBinaryName = await getCliBinaryName()

Check failure on line 21 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`

const RNC_CLI_BINARY_PATH = path.resolve(
process.cwd(), // We are always expected to run in the library
'node_modules',
'.bin',
rncCliBinaryName
);

return await spawn(NODE_BINARY, [RNC_CLI_BINARY_PATH, ...args], options);
}

async function getCliBinaryName(): Promise<string | undefined> {
const rncCliPackagePath = await spawn(NODE_BINARY, [
'-e',
`console.log(require.resolve('@react-native-community/cli/package.json'))`

Check failure on line 36 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `,`
])

Check failure on line 37 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`

const rncCliPackage = await fs.readJson(rncCliPackagePath)

Check failure on line 39 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`
const binaries = rncCliPackage.bin as Record<string, string>

Check failure on line 40 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`
assert(typeof (binaries) === 'object', 'React Native CLI doesn\'t specify proper binaries')

Check failure on line 41 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Replace `typeof·(binaries)·===·'object',·'React·Native·CLI·doesn\'t·specify·proper·binaries')` with `⏎····typeof·binaries·===·'object',⏎····"React·Native·CLI·doesn't·specify·proper·binaries"⏎··);`

return Object.keys(binaries)[0]

Check failure on line 43 in packages/react-native-builder-bob/src/utils/runRNCCli.ts

View workflow job for this annotation

GitHub Actions / check-project

Insert `;`
}

0 comments on commit 5840521

Please sign in to comment.