Skip to content

Commit 0f2e41e

Browse files
authored
feat: add custom path to config (#107)
* feat: add custom path to config * fix tests
1 parent ef09634 commit 0f2e41e

5 files changed

Lines changed: 17 additions & 0 deletions

File tree

bin/bumpp.mjs

100644100755
File mode changed.

src/cli/parse-args.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function parseArgs(): Promise<ParsedArgs> {
4747
printCommits: args.printCommits,
4848
recursive: args.recursive,
4949
release: args.release,
50+
configFilePath: args.configFilePath,
5051
}),
5152
}
5253

@@ -94,6 +95,7 @@ export function loadCliArgs(argv = process.argv) {
9495
.option('--print-commits', 'Print recent commits')
9596
.option('-x, --execute <command>', 'Commands to execute after version bumps')
9697
.option('--release <release>', `Release type or version number (e.g. 'major', 'minor', 'patch', 'prerelease', etc. default: ${bumpConfigDefaults.release})`)
98+
.option('--configFilePath <configFilePath>', `Path to custom build.config file`)
9799
.help()
98100

99101
const result = cli.parse(argv)

src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const bumpConfigDefaults: VersionBumpOptions = {
1717
all: false,
1818
noGitCheck: true,
1919
files: [],
20+
configFilePath: undefined,
2021
}
2122

2223
export async function loadBumpConfig(
@@ -28,6 +29,7 @@ export async function loadBumpConfig(
2829
const { config } = await loadConfig<VersionBumpOptions>({
2930
name,
3031
defaults: bumpConfigDefaults,
32+
configFile: overrides?.configFilePath || undefined,
3133
overrides: {
3234
...(overrides as VersionBumpOptions),
3335
},

src/types/version-bump-options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ export interface VersionBumpOptions {
157157
*/
158158
printCommits?: boolean
159159

160+
/**
161+
* The path to the config file
162+
* If not provided, it will be inferred from the current working directory.
163+
* @default undefined
164+
*/
165+
configFilePath?: string
166+
160167
/**
161168
* Custom function to provide the version number
162169
*/

test/parse-args.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ describe('loadCliArgs', async () => {
6565

6666
expect(result.args.sign).toBe(true)
6767
})
68+
69+
it('should have configFilePath property set to the value of the `--configFilePath` flag', () => {
70+
const result = loadCliArgs([...defaultArgs, '--configFilePath', 'test/fixtures/build.config.ts'])
71+
72+
expect(result.args.configFilePath).toBe('test/fixtures/build.config.ts')
73+
})
6874
})

0 commit comments

Comments
 (0)