@@ -27,7 +27,7 @@ const templateOption = new Option('--template <type>', 'template to scaffold').c
27
27
templateChoices
28
28
) ;
29
29
30
- const ProjectPathSchema = v . string ( ) ;
30
+ const ProjectPathSchema = v . optional ( v . string ( ) ) ;
31
31
const OptionsSchema = v . strictObject ( {
32
32
types : v . pipe (
33
33
v . optional ( v . union ( [ v . picklist ( langs ) , v . boolean ( ) ] ) ) ,
@@ -38,10 +38,11 @@ const OptionsSchema = v.strictObject({
38
38
template : v . optional ( v . picklist ( templateChoices ) )
39
39
} ) ;
40
40
type Options = v . InferOutput < typeof OptionsSchema > ;
41
+ type ProjectPath = v . InferOutput < typeof ProjectPathSchema > ;
41
42
42
43
export const create = new Command ( 'create' )
43
44
. description ( 'scaffolds a new SvelteKit project' )
44
- . argument ( '[path]' , 'where the project will be created' , process . cwd ( ) )
45
+ . argument ( '[path]' , 'where the project will be created' )
45
46
. addOption ( templateOption )
46
47
. addOption ( langOption )
47
48
. option ( '--no-types' )
@@ -58,7 +59,8 @@ export const create = new Command('create')
58
59
let i = 1 ;
59
60
const initialSteps : string [ ] = [ ] ;
60
61
const relative = path . relative ( process . cwd ( ) , directory ) ;
61
- const pm = packageManager ?? detectSync ( { cwd } ) ?. name ?? common . getUserAgent ( ) ?? 'npm' ;
62
+ const pm =
63
+ packageManager ?? detectSync ( { cwd : directory } ) ?. name ?? common . getUserAgent ( ) ?? 'npm' ;
62
64
if ( relative !== '' ) {
63
65
const pathHasSpaces = relative . includes ( ' ' ) ;
64
66
initialSteps . push (
@@ -85,12 +87,13 @@ export const create = new Command('create')
85
87
} ) ;
86
88
} ) ;
87
89
88
- async function createProject ( cwd : string , options : Options ) {
90
+ async function createProject ( cwd : ProjectPath , options : Options ) {
89
91
const { directory, template, language } = await p . group (
90
92
{
91
93
directory : ( ) => {
92
- const relativePath = path . relative ( process . cwd ( ) , cwd ) ;
93
- if ( relativePath ) return Promise . resolve ( relativePath ) ;
94
+ if ( cwd ) {
95
+ return Promise . resolve ( path . resolve ( cwd ) ) ;
96
+ }
94
97
const defaultPath = './' ;
95
98
return p . text ( {
96
99
message : 'Where would you like your project to be created?' ,
0 commit comments