File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { downloadTemplate , startShell } from 'giget'
2
2
import type { DownloadTemplateResult } from 'giget'
3
- import { relative , resolve } from 'pathe'
3
+ import { relative , resolve , join } from 'pathe'
4
4
import { consola } from 'consola'
5
5
import { installDependencies } from 'nypm'
6
6
import type { PackageManagerName } from 'nypm'
7
7
import { defineCommand } from 'citty'
8
+ import { readPackageJSON , writePackageJSON } from 'pkg-types'
8
9
9
10
import { sharedArgs } from './_shared'
10
11
@@ -83,6 +84,13 @@ export default defineCommand({
83
84
preferOffline : Boolean ( ctx . args . preferOffline ) ,
84
85
registry : process . env . NUXI_INIT_REGISTRY || DEFAULT_REGISTRY ,
85
86
} )
87
+
88
+ if ( ctx . args . dir . length > 0 ) {
89
+ const pkg = await readPackageJSON ( template . dir )
90
+ // Handles paths like ../some/dir with sane fallback
91
+ pkg . name = ctx . args . dir . split ( '/' ) . at ( - 1 ) || pkg . name
92
+ await writePackageJSON ( join ( template . dir , 'package.json' ) , pkg )
93
+ }
86
94
}
87
95
catch ( err ) {
88
96
if ( process . env . DEBUG ) {
You can’t perform that action at this time.
0 commit comments