Skip to content

Commit d71735f

Browse files
committed
fix(installation): run install using Bun if available
release-npm
1 parent cac24d4 commit d71735f

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@ customize(name, destinationDirectory)
4848

4949
console.log('Installing dependencies...')
5050

51-
execSync('npm install --legacy-peer-deps', {
52-
cwd: destinationDirectory,
53-
stdio: 'inherit',
54-
})
51+
// biome-ignore lint/correctness/noUndeclaredVariables: Used to detect Bun as the runtime.
52+
if (typeof Bun !== 'undefined') {
53+
execSync('bun install', {
54+
cwd: destinationDirectory,
55+
stdio: 'inherit',
56+
})
57+
} else {
58+
execSync('npm install --legacy-peer-deps', {
59+
cwd: destinationDirectory,
60+
stdio: 'inherit',
61+
})
62+
}
5563

5664
console.log('')
5765
console.log(`😃 Created new plugin called ${name.regular} in ${destinationDirectory}.`)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@biomejs/biome": "^1.8.1",
16-
"zero-configuration": "^0.10.1"
16+
"zero-configuration": "^0.12.0"
1717
},
1818
"trustedDependencies": [
1919
"zero-configuration"

template/create-app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#!/usr/bin/env node
21
import { copyFileSync, renameSync, rmSync } from 'fs'
32
import { join } from 'path'
43
import { execSync } from 'child_process'
54

65
// This script enhances source files inside /app with a fresh React Native template.
76
const appName = '<%= pascal %>App'
7+
const isBun = typeof Bun !== 'undefined'
88

99
console.log('⌛ Initializing a fresh RN project...')
1010

11-
execSync(`npx react-native init ${appName} --skip-git-init true --install-pods true`, {
11+
execSync(`${isBun ? 'bunx' : 'npx'} react-native init ${appName} --skip-git-init true --install-pods true`, {
1212
// Write output to cnosole.
1313
stdio: 'inherit',
1414
})
@@ -20,7 +20,7 @@ rmSync('app', { recursive: true })
2020
renameSync(appName, 'app')
2121

2222
// Run build to ensure distributed files for plugin exist.
23-
execSync('npm run build', {
23+
execSync(`${isBun ? 'bun' : 'npm'} run build`, {
2424
stdio: 'inherit',
2525
})
2626

template/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"scripts": {
66
"app": "node create-app.js",
77
"app:install": "npm i --no-save $(npm pack . | tail -1) --prefix app",
8-
"build": "esbuild index.tsx --outdir=dist --bundle --format=esm --sourcemap --external:react-native --external:react && tsc",
8+
"build": "esbuild index.tsx --outdir=dist --bundle --format=esm --sourcemap --external:react-native --external:react",
99
"watch": "npm-run-all --parallel build:watch copy",
1010
"copy": "cpx 'dist/**/*' app/node_modules/<%= name %>/dist --watch",
1111
"build:watch": "esbuild index.tsx --watch --outdir=dist --bundle --format=esm --sourcemap --external:react-native --external:react",
1212
"test": "jest",
1313
"test:watch": "jest --watchAll",
14+
"types": "tsc",
1415
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
1516
"format": "prettier \"{,!(app|dist)/**/}*.{ts,tsx}\" --write"
1617
},

0 commit comments

Comments
 (0)