Skip to content

Commit 2dad5f2

Browse files
committed
fix: do not create .gitignore files for monorepo workspace projects
1 parent 1cefa04 commit 2dad5f2

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/check-project/index.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,9 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) {
131131
proposedManifest = sortManifest(proposedManifest)
132132

133133
await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
134-
135-
if (!isMonorepoProject) {
136-
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
137-
encoding: 'utf-8'
138-
}))
139-
}
140-
134+
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
135+
encoding: 'utf-8'
136+
}))
141137
await checkLicenseFiles(projectDir)
142138
await checkBuildFiles(projectDir, branchName, repoUrl)
143139
await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs)
@@ -396,7 +392,7 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag
396392

397393
await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
398394

399-
if (!isMonorepoProject) {
395+
if (!isMonorepoProject(projectDir)) {
400396
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
401397
encoding: 'utf-8'
402398
}))

src/release.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const tasks = new Listr([
2525
}
2626
},
2727
{
28-
title: `semantic-release${isMonorepoProject ? '-monorepo' : ''}`,
28+
title: `semantic-release${isMonorepoProject() ? '-monorepo' : ''}`,
2929
/**
3030
* @param {GlobalOptions} ctx
3131
*/
3232
task: async (ctx) => {
3333
let args = ctx['--'] ?? []
3434

35-
if (isMonorepoProject) {
35+
if (isMonorepoProject()) {
3636
args = ['-e', 'semantic-release-monorepo', ...args]
3737
}
3838

@@ -44,7 +44,7 @@ const tasks = new Listr([
4444
},
4545
{
4646
title: 'align sibling dependency versions',
47-
enabled: () => isMonorepoProject,
47+
enabled: () => isMonorepoProject(),
4848
/**
4949
* @param {GlobalOptions & ReleaseOptions} ctx
5050
*/

src/utils.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,11 @@ export const isTypedCJS = isCJS && hasMain && hasTypes
268268
// 3. CJS, no types
269269
export const isUntypedCJS = isCJS && hasMain
270270

271-
const parentManifestPath = path.resolve(path.join(process.cwd(), '..', '..', 'package.json'))
271+
export const isMonorepoProject = (dir = process.cwd()) => {
272+
const parentManifestPath = path.resolve(dir, '..', '..', 'package.json')
272273

273-
export const isMonorepoProject = Boolean(fs.existsSync(parentManifestPath) && fs.readJSONSync(parentManifestPath).workspaces)
274+
return Boolean(fs.existsSync(parentManifestPath) && fs.readJSONSync(parentManifestPath).workspaces)
275+
}
274276

275277
/**
276278
* Binaries we need are normally in `node_modules/.bin` of the root project

0 commit comments

Comments
 (0)