@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
import * as find from 'empathic/find' ;
4
4
import { common , object , type AstTypes } from '@sveltejs/cli-core/js' ;
5
5
import { parseScript } from '@sveltejs/cli-core/parsers' ;
6
- import { detectSync } from 'package-manager-detector' ;
6
+ import { detect } from 'package-manager-detector' ;
7
7
import type { OptionValues , PackageManager , Workspace } from '@sveltejs/cli-core' ;
8
8
import { TESTING } from '../../utils/env.ts' ;
9
9
import { commonFilePaths , getPackageJson , readFile } from './utils.ts' ;
@@ -14,11 +14,11 @@ type CreateWorkspaceOptions = {
14
14
packageManager ?: PackageManager ;
15
15
options ?: OptionValues < any > ;
16
16
} ;
17
- export function createWorkspace ( {
17
+ export async function createWorkspace ( {
18
18
cwd,
19
19
options = { } ,
20
- packageManager = detectSync ( { cwd } ) ?. name ?? getUserAgent ( ) ?? 'npm'
21
- } : CreateWorkspaceOptions ) : Workspace < any > {
20
+ packageManager
21
+ } : CreateWorkspaceOptions ) : Promise < Workspace < any > > {
22
22
const resolvedCwd = path . resolve ( cwd ) ;
23
23
const viteConfigPath = path . join ( resolvedCwd , commonFilePaths . viteConfigTS ) ;
24
24
let usesTypescript = fs . existsSync ( viteConfigPath ) ;
@@ -53,7 +53,7 @@ export function createWorkspace({
53
53
return {
54
54
cwd : resolvedCwd ,
55
55
options,
56
- packageManager,
56
+ packageManager : packageManager ?? ( await detect ( { cwd } ) ) ?. name ?? getUserAgent ( ) ?? 'npm' ,
57
57
typescript : usesTypescript ,
58
58
kit : dependencies [ '@sveltejs/kit' ] ? parseKitOptions ( resolvedCwd ) : undefined ,
59
59
dependencyVersion : ( pkg ) => dependencies [ pkg ]
0 commit comments