mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
This commit is contained in:
5
.changes/cta-react-disable-open-browser.md
Normal file
5
.changes/cta-react-disable-open-browser.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"create-tauri-app": patch
|
||||
---
|
||||
|
||||
Stop react recipe from opening in browser by default.
|
||||
@@ -7,10 +7,14 @@ import { join } from 'path'
|
||||
|
||||
interface Package {
|
||||
name?: string
|
||||
scripts?: {}
|
||||
scripts?: Record<string, string>
|
||||
}
|
||||
|
||||
export function updatePackageJson(appDirectory: string, appName: string): void {
|
||||
export function updatePackageJson(
|
||||
appDirectory: string,
|
||||
appName: string,
|
||||
recipeShortName: string
|
||||
): void {
|
||||
const pkgPath = join(appDirectory, 'package.json')
|
||||
const pkgString = readFileSync(pkgPath, 'utf8')
|
||||
const pkg = JSON.parse(pkgString) as Package
|
||||
@@ -19,6 +23,9 @@ export function updatePackageJson(appDirectory: string, appName: string): void {
|
||||
name: appName,
|
||||
scripts: {
|
||||
...pkg.scripts,
|
||||
start: `${recipeShortName === 'cra' ? 'cross-env BROWSER=none ' : ''}${
|
||||
pkg.scripts?.start as string
|
||||
}`,
|
||||
tauri: 'tauri'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ const runInit = async (argv: Argv): Promise<void> => {
|
||||
})
|
||||
|
||||
logStep(`Updating ${reset(yellow('"package.json"'))}`)
|
||||
updatePackageJson(appDirectory, appName)
|
||||
updatePackageJson(appDirectory, appName, recipe.shortName)
|
||||
|
||||
logStep(`Running ${reset(yellow('"tauri init"'))}`)
|
||||
const binary = !argv.b ? packageManager : resolve(appDirectory, argv.b)
|
||||
|
||||
@@ -46,7 +46,7 @@ export const cra: Recipe = {
|
||||
packageManager === 'npm' ? 'npm run' : packageManager
|
||||
} build`
|
||||
}),
|
||||
extraNpmDevDependencies: [],
|
||||
extraNpmDevDependencies: ['cross-env'],
|
||||
extraNpmDependencies: [],
|
||||
extraQuestions: ({ ci }) => {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user