Skip to content

Commit 261e796

Browse files
jherrFatahChan
andauthored
fix: install with npm when using other pm (#47)
Co-authored-by: FatahChan <[email protected]>
1 parent 0b6c280 commit 261e796

File tree

8 files changed

+37
-51
lines changed

8 files changed

+37
-51
lines changed

src/create-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export async function createApp(
352352
copyFiles(templateDirBase, ['./toolchain/biome.json'], true)
353353
}
354354

355-
// Setup the main, reportWebVitals and index.html files
355+
// Setup reportWebVitals
356356
if (!isAddOnEnabled('start') && options.framework === 'react') {
357357
if (options.typescript) {
358358
await templateFile(templateDirBase, './src/reportWebVitals.ts.ejs')

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function normalizeOptions(
5252
projectName: cliOptions.projectName,
5353
typescript,
5454
tailwind,
55-
packageManager: cliOptions.packageManager || DEFAULT_PACKAGE_MANAGER,
55+
packageManager: cliOptions.packageManager || getPackageManager() || DEFAULT_PACKAGE_MANAGER,
5656
toolchain: cliOptions.toolchain || DEFAULT_TOOLCHAIN,
5757
mode: cliOptions.template === 'file-router' ? FILE_ROUTER : CODE_ROUTER,
5858
git: !!cliOptions.git,

src/package-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export function getPackageManager(): PackageManager | undefined {
1919
userAgent.startsWith(manager),
2020
)
2121

22-
return packageManager || DEFAULT_PACKAGE_MANAGER
22+
return packageManager
2323
}

tests/snapshots/cra/cr-js-npm.json

Lines changed: 7 additions & 9 deletions
Large diffs are not rendered by default.

tests/snapshots/cra/cr-ts-npm.json

Lines changed: 8 additions & 10 deletions
Large diffs are not rendered by default.

tests/snapshots/cra/fr-ts-npm.json

Lines changed: 8 additions & 10 deletions
Large diffs are not rendered by default.

tests/snapshots/cra/fr-ts-tw-npm.json

Lines changed: 8 additions & 10 deletions
Large diffs are not rendered by default.

tests/test-utilities.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFile } from 'node:fs/promises'
2-
import { dirname, resolve, basename, extname } from 'node:path'
2+
import { dirname, join, basename, extname } from 'node:path'
33

44
import { createDefaultEnvironment } from '../src/environment.js'
55

@@ -13,7 +13,6 @@ export function createTestEnvironment(projectName: string) {
1313
commands: Array<{
1414
command: string
1515
args: Array<string>
16-
cwd: string
1716
}>
1817
} = {
1918
files: {},
@@ -22,7 +21,7 @@ export function createTestEnvironment(projectName: string) {
2221

2322
const isTemplatePath = (path: string) => dirname(path).includes('templates')
2423
const trimProjectRelativePath = (path: string) =>
25-
resolve(
24+
join(
2625
dirname(path).replace(new RegExp(`^.*/${projectName}`), ''),
2726
basename(path),
2827
)
@@ -38,15 +37,10 @@ export function createTestEnvironment(projectName: string) {
3837
output.files[relPath] = contents
3938
}
4039
}
41-
environment.execute = async (
42-
command: string,
43-
args: Array<string>,
44-
cwd: string,
45-
) => {
40+
environment.execute = async (command: string, args: Array<string>) => {
4641
output.commands.push({
4742
command,
4843
args,
49-
cwd,
5044
})
5145
}
5246
environment.readFile = async (path: string, encoding?: BufferEncoding) => {

0 commit comments

Comments
 (0)