@@ -3,6 +3,7 @@ import { mkdir, writeFile } from "fs/promises";
33import { join } from "path" ;
44import prompts from "prompts" ;
55import { generateReadme } from "../templates/readme.js" ;
6+ import { platform } from "os" ;
67
78export async function createProject ( name ?: string ) {
89 let projectName : string ;
@@ -119,22 +120,17 @@ export default ExampleTool;`;
119120
120121 console . log ( "Creating project files..." ) ;
121122 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 ) ) ,
130125 writeFile ( join ( projectDir , "README.md" ) , generateReadme ( projectName ) ) ,
131126 writeFile ( join ( srcDir , "index.ts" ) , indexTs ) ,
132127 writeFile ( join ( toolsDir , "ExampleTool.ts" ) , exampleToolTs ) ,
133128 ] ) ;
134129
130+ process . chdir ( projectDir ) ;
131+
135132 console . log ( "Initializing git repository..." ) ;
136133 const gitInit = spawnSync ( "git" , [ "init" ] , {
137- cwd : projectDir ,
138134 stdio : "inherit" ,
139135 shell : true ,
140136 } ) ;
@@ -145,7 +141,6 @@ export default ExampleTool;`;
145141
146142 console . log ( "Installing dependencies..." ) ;
147143 const npmInstall = spawnSync ( "npm" , [ "install" ] , {
148- cwd : projectDir ,
149144 stdio : "inherit" ,
150145 shell : true ,
151146 } ) ;
@@ -156,9 +151,9 @@ export default ExampleTool;`;
156151
157152 console . log ( "Building project..." ) ;
158153 const npmBuild = spawnSync ( "npm" , [ "run" , "build" ] , {
159- cwd : projectDir ,
160154 stdio : "inherit" ,
161155 shell : true ,
156+ env : process . env
162157 } ) ;
163158
164159 if ( npmBuild . status !== 0 ) {
0 commit comments