-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stages): implement initVersionControl
- Loading branch information
1 parent
6693db6
commit 24da5e1
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './copyFiles'; | ||
export * from './renderTemplates'; | ||
export * from './installDependencies'; | ||
export * from './initVersionControl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import execa from 'execa'; | ||
import * as fse from 'fs-extra'; | ||
import type { ParamsContext } from '../../params'; | ||
|
||
export async function initVersionControl( | ||
context: ParamsContext, | ||
): Promise<void> { | ||
const { targetDir } = context; | ||
const execaOption: execa.Options = { cwd: targetDir }; | ||
|
||
if ( | ||
fse.pathExistsSync(`${targetDir}/.npmignore`) && | ||
!fse.pathExistsSync(`${targetDir}/.gitignore`) | ||
) { | ||
await fse.move(`${targetDir}/.npmignore`, `${targetDir}/.gitignore`); | ||
} | ||
await execa('git', ['init'], execaOption); | ||
await execa('git', ['add', '-A'], execaOption); | ||
await execa( | ||
'git', | ||
['commit', '-m', 'Initialize by create-krome-app'], | ||
execaOption, | ||
); | ||
} |