diff --git a/src/index.ts b/src/index.ts index c8bb5e8..b03d009 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,11 @@ const dotnetCommands = [ 'dotnet build', ]; +const gitCommands = [ + "git init", + "git add .", +]; + async function execShellCommand(command: string, targetPath: string) { const startTime = performance.now(); const spinner = createSpinner(`Running '${command}'...`).start(); @@ -84,6 +89,16 @@ const generateProject = new Promise(async (resolve, reject) => { } } + if (answers.initGitRepo) { + try { + for (const command of gitCommands) { + await execShellCommand(command, targetPath); + } + } catch (e) { + return reject(e); + } + } + console.timeEnd("Done in"); return resolve(); }); diff --git a/src/parameters.ts b/src/parameters.ts index ed1bfba..a8e77e5 100644 --- a/src/parameters.ts +++ b/src/parameters.ts @@ -86,6 +86,14 @@ export default [ message: 'Initial version', initial: '0.0.1', }, + { + type: 'toggle', + name: 'initGitRepo', + message: 'Initialize a git repository?', + initial: true, + active: 'yes', + inactive: 'no', + }, { type: 'toggle', name: 'setupUsingDotnetCli',