|
1 | 1 | 'use strict'
|
2 | 2 | const chalk = require('chalk')
|
3 | 3 | const { execSync } = require('child_process')
|
4 |
| -const createGit = require('create-git') |
5 | 4 | const createPackageJson = require('create-package-json')
|
6 | 5 | const fs = require('fs-extra')
|
7 | 6 | const path = require('path')
|
@@ -77,28 +76,20 @@ module.exports = async ({ directory, withFetch, withDocker, prompt }) => {
|
77 | 76 | }
|
78 | 77 |
|
79 | 78 | await createPackageJson(packageOptions)
|
80 |
| - log(`${step('NPM')} Initialized npm package and installed dependencies`) |
| 79 | + log(`${step('NPM')} Initialized npm package and installed dependencies.`) |
81 | 80 |
|
82 |
| - await createGit({ |
83 |
| - silent: prompt, |
84 |
| - cwd: directory, |
85 |
| - primaryBranch: 'master', |
86 |
| - ignoreExisting: true, |
87 |
| - initialCommitMessage: 'init: :tada: initial commit', |
88 |
| - remoteOrigin: '', |
89 |
| - ignoreTemplates: [], |
90 |
| - additionalRules: [], |
91 |
| - push: false, |
92 |
| - commitAll: true, |
93 |
| - }) |
94 |
| - log(`${step('GIT')} Initialized git repository`) |
| 81 | + const createGitCommand = `cd ${directory} && git init` |
| 82 | + if (runCommand(createGitCommand)) log(`${step('GIT')} Initialized git repository.`) |
95 | 83 |
|
96 | 84 | const createLocalEnvCommand = `cd ${directory} && cp .env.example .env`
|
97 |
| - const localEnvResult = runCommand(createLocalEnvCommand) |
98 |
| - if (localEnvResult) log(`${step('ENV')} Created local .env file`) |
| 85 | + if (runCommand(createLocalEnvCommand)) log(`${step('ENV')} Created local .env file.`) |
99 | 86 |
|
100 | 87 | const huskyCommand = `cd ${directory} && npm set-script prepare "husky install" && npm run prepare &&
|
101 | 88 | npx husky add .husky/pre-commit "npx lint-staged"`
|
102 |
| - const huskyResult = runCommand(huskyCommand) |
103 |
| - if (huskyResult) log(`${step('HUSKY')} Initialized husky hook`) |
| 89 | + if (runCommand(huskyCommand)) log(`${step('HUSKY')} Initialized husky hook.`) |
| 90 | + |
| 91 | + const initialCommitCommand = `cd ${directory} && git add . && git commit ${ |
| 92 | + !prompt ? '--quiet' : '' |
| 93 | + } -m "init: :tada: initial commit"` |
| 94 | + if (runCommand(initialCommitCommand)) log(`${step('COMMIT')} Created initial commit.`) |
104 | 95 | }
|
0 commit comments