Skip to content

Commit 0eace6c

Browse files
committed
fix: do not create .gitignore in monorepo workspaces
Only update .gitignore for monrepo roots
1 parent 471605e commit 0eace6c

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/check-project/index.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import semver from 'semver'
2424
import Listr from 'listr'
2525
import yargsParser from 'yargs-parser'
2626
import { fileURLToPath } from 'url'
27+
import {
28+
isMonorepoProject
29+
} from '../utils.js'
2730

2831
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2932

@@ -128,9 +131,13 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) {
128131
proposedManifest = sortManifest(proposedManifest)
129132

130133
await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
131-
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
132-
encoding: 'utf-8'
133-
}))
134+
135+
if (!isMonorepoProject) {
136+
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
137+
encoding: 'utf-8'
138+
}))
139+
}
140+
134141
await checkLicenseFiles(projectDir)
135142
await checkBuildFiles(projectDir, branchName, repoUrl)
136143
await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs)
@@ -388,9 +395,13 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag
388395
proposedManifest = sortManifest(proposedManifest)
389396

390397
await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
391-
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
392-
encoding: 'utf-8'
393-
}))
398+
399+
if (!isMonorepoProject) {
400+
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
401+
encoding: 'utf-8'
402+
}))
403+
}
404+
394405
await checkLicenseFiles(projectDir)
395406
await checkReadme(projectDir, repoUrl, branchName, rootManifest)
396407
}

src/check-project/utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export async function ensureFileHasContents (projectDir, filePath, expectedConte
6060
})
6161

6262
if (!createFile) {
63-
throw new Error(`Not creating ${filePath} file`)
63+
console.warn(kleur.yellow(`${filePath} did not exist`))
64+
return
6465
}
6566

6667
fs.mkdirSync(path.dirname(path.join(projectDir, filePath)), {

0 commit comments

Comments
 (0)