This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
forked from streamich/git-cz
-
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.
♻️ grep package.json old-fashioned way
This allows us to have a folder to folder ratio with dist <=> src
- Loading branch information
1 parent
d7b0ecd
commit 0911dc9
Showing
6 changed files
with
70 additions
and
11 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
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,47 @@ | ||
/* eslint-disable global-require, import/no-dynamic-require, operator-linebreak */ | ||
import path from 'path' | ||
import fs from 'fs' | ||
|
||
const configFiles = ['package.json'] | ||
|
||
const findOverrides = (root) => { | ||
const dir = root || process.cwd() | ||
|
||
for (const file of configFiles) { | ||
const filename = path.resolve(dir, file) | ||
|
||
if (fs.existsSync(filename) && fs.statSync(filename).isFile()) { | ||
return require(filename) | ||
} | ||
} | ||
|
||
const parent = path.resolve(dir, '..') | ||
|
||
if (parent !== dir) { | ||
return findOverrides(parent) | ||
} | ||
|
||
const pkgFilename = path.join(dir, 'package.json') | ||
|
||
if (fs.existsSync(pkgFilename)) { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const changelog = require(pkgFilename).config.commitizen.changelog | ||
|
||
if (changelog) { | ||
return changelog | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (error) {} | ||
} | ||
|
||
return {} | ||
} | ||
|
||
const getConfig = (root) => { | ||
const overrides = findOverrides(root) | ||
|
||
return { ...overrides } | ||
} | ||
|
||
export default getConfig |
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