@@ -3,6 +3,7 @@ import { mkdir, writeFile } from "fs/promises";
3
3
import { join } from "path" ;
4
4
import prompts from "prompts" ;
5
5
import { generateReadme } from "../templates/readme.js" ;
6
+ import { platform } from "os" ;
6
7
7
8
export async function createProject ( name ?: string ) {
8
9
let projectName : string ;
@@ -119,22 +120,17 @@ export default ExampleTool;`;
119
120
120
121
console . log ( "Creating project files..." ) ;
121
122
await Promise . all ( [
122
- writeFile (
123
- join ( projectDir , "package.json" ) ,
124
- JSON . stringify ( packageJson , null , 2 )
125
- ) ,
126
- writeFile (
127
- join ( projectDir , "tsconfig.json" ) ,
128
- JSON . stringify ( tsconfig , null , 2 )
129
- ) ,
123
+ writeFile ( join ( projectDir , "package.json" ) , JSON . stringify ( packageJson , null , 2 ) ) ,
124
+ writeFile ( join ( projectDir , "tsconfig.json" ) , JSON . stringify ( tsconfig , null , 2 ) ) ,
130
125
writeFile ( join ( projectDir , "README.md" ) , generateReadme ( projectName ) ) ,
131
126
writeFile ( join ( srcDir , "index.ts" ) , indexTs ) ,
132
127
writeFile ( join ( toolsDir , "ExampleTool.ts" ) , exampleToolTs ) ,
133
128
] ) ;
134
129
130
+ process . chdir ( projectDir ) ;
131
+
135
132
console . log ( "Initializing git repository..." ) ;
136
133
const gitInit = spawnSync ( "git" , [ "init" ] , {
137
- cwd : projectDir ,
138
134
stdio : "inherit" ,
139
135
shell : true ,
140
136
} ) ;
@@ -145,7 +141,6 @@ export default ExampleTool;`;
145
141
146
142
console . log ( "Installing dependencies..." ) ;
147
143
const npmInstall = spawnSync ( "npm" , [ "install" ] , {
148
- cwd : projectDir ,
149
144
stdio : "inherit" ,
150
145
shell : true ,
151
146
} ) ;
@@ -156,9 +151,9 @@ export default ExampleTool;`;
156
151
157
152
console . log ( "Building project..." ) ;
158
153
const npmBuild = spawnSync ( "npm" , [ "run" , "build" ] , {
159
- cwd : projectDir ,
160
154
stdio : "inherit" ,
161
155
shell : true ,
156
+ env : process . env
162
157
} ) ;
163
158
164
159
if ( npmBuild . status !== 0 ) {
0 commit comments