Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit847aa92

Browse files
authored
fix: skip creating a git repo when inside existing repo (#920)
* test: skip creating a git repo when inside existing repo* fix: skip creating git repo inside existing repo* test: use proper paths for project files* test: use absolute paths when checking existence to avoid quantum tangling multiple dimensions and causing the universe to stop existing
1 parente6d411d commit847aa92

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎__tests__/index-test.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,29 @@ describe('yes', () => {
141141
expect(fileExists(projectName,'.gitignore')).toBeTruthy();
142142
expect(fileExists(projectName,'node_modules')).not.toBeTruthy();
143143
});
144+
it('does not create a new git repository inside an existing repository',async()=>{
145+
constworkspaceName='yes-skip-git-in-repo';
146+
constworkspaceRoot=getRoot(workspaceName);
147+
148+
// Create the workspace root, and basic monorepo structure
149+
awaitfs.mkdirp(workspaceRoot);
150+
awaitexeca('git',['init'],{cwd:workspaceRoot});
151+
152+
// Create the app within a basic monorepo structure
153+
constprojectRoot=path.join(workspaceRoot,'apps',workspaceName);
154+
awaitfs.mkdirp(projectRoot);
155+
156+
constresults=awaitexeca('node',[cli,'--yes'],{cwd:projectRoot});
157+
expect(results.exitCode).toBe(0);
158+
159+
expect(existsSync(path.join(workspaceRoot,'.git'))).toBe(true);
160+
expect(existsSync(path.join(projectRoot,'.git'))).not.toBe(true);
161+
162+
expect(existsSync(path.join(projectRoot,'package.json'))).toBe(true);
163+
expect(existsSync(path.join(projectRoot,'App.js'))).toBe(true);
164+
expect(existsSync(path.join(projectRoot,'.gitignore'))).toBe(true);
165+
expect(existsSync(path.join(projectRoot,'node_modules'))).toBe(true);
166+
});
144167
});
145168

146169
describe('templates',()=>{

‎src/Template.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export async function initGitRepoAsync(
110110
try{
111111
awaitspawnAsync('git',['rev-parse','--is-inside-work-tree'],{stdio:'ignore',cwd:root});
112112
!flags.silent&&Logger.gray('New project is already inside of a Git repo, skipping git init.');
113+
returnfalse;
113114
}catch(e){
114115
if(e.errno==='ENOENT'){
115116
!flags.silent&&Logger.gray('Unable to initialize Git repo. `git` not in PATH.');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp