Skip to content

Commit

Permalink
fix: do not create .gitignore in monorepo workspaces
Browse files Browse the repository at this point in the history
Only update .gitignore for monrepo roots
  • Loading branch information
achingbrain committed Feb 15, 2023
1 parent 471605e commit 0eace6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/check-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import semver from 'semver'
import Listr from 'listr'
import yargsParser from 'yargs-parser'
import { fileURLToPath } from 'url'
import {
isMonorepoProject
} from '../utils.js'

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

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

await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
encoding: 'utf-8'
}))

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

await checkLicenseFiles(projectDir)
await checkBuildFiles(projectDir, branchName, repoUrl)
await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs)
Expand Down Expand Up @@ -388,9 +395,13 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag
proposedManifest = sortManifest(proposedManifest)

await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
encoding: 'utf-8'
}))

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

await checkLicenseFiles(projectDir)
await checkReadme(projectDir, repoUrl, branchName, rootManifest)
}
Expand Down
3 changes: 2 additions & 1 deletion src/check-project/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export async function ensureFileHasContents (projectDir, filePath, expectedConte
})

if (!createFile) {
throw new Error(`Not creating ${filePath} file`)
console.warn(kleur.yellow(`${filePath} did not exist`))
return
}

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

0 comments on commit 0eace6c

Please sign in to comment.