From 767be6701b876f3ce893cc784a3f9c0edcce9793 Mon Sep 17 00:00:00 2001 From: Ossama Jouini Date: Sun, 19 Jan 2025 16:27:53 +0900 Subject: [PATCH] Fix bug with new init --- build/init.js | 25 ++++++++++++++++--------- package.json | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/build/init.js b/build/init.js index ea76de4..46133e0 100644 --- a/build/init.js +++ b/build/init.js @@ -1,18 +1,25 @@ import fs from "fs"; import open from "open"; -import { execSync } from "child_process"; +import { exec } from "child_process"; import * as chalkUtils from "./chalkUtils.js"; import fromConsole from "./fromConsole.js"; export default function initialiseProject() { - console.log(execSync("npm install")); - console.log(execSync("npm run updateProjectData")); - if (!fs.existsSync(".git")) { - console.log(execSync("git init")); - console.log(execSync("git add -A")); - console.log(execSync('git commit -m "Initial commit"')); - open("https://github.com/new"); - } + let process = exec("npm install && npm run updateProjectData"); + process.stdout.pipe(process.stdout); + process.stderr.pipe(process.stderr); + process.on("exit", () => { + if (!fs.existsSync(".git")) { + let process2 = exec( + "git init && git add -A && git commit -m 'Initial commit'" + ); + process2.stdout.pipe(process2.stdout); + process2.stderr.pipe(process2.stderr); + process2.on("exit", () => { + open("https://github.com/new"); + }); + } + }); } if (fromConsole(import.meta.url)) { diff --git a/package.json b/package.json index 3ee4a21..e0daa56 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "build": "cd build && node build.js", "dev": "cd build && node dev.js", "updateProjectData": "cd build && node updateProjectData.js", - "init": "npm install && cd build && node init.js", + "init": "node init.js", "generateDocs": "cd build && node generateDocumentation.js", "publish": "cd build && node publish.js" },