Skip to content

Commit db5a46a

Browse files
authored
feat: .git-town.toml support (#57)
1 parent 2be2dfa commit db5a46a

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

dist/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47460,16 +47460,19 @@ var configSchema = object({
4746047460
"perennial-regex": string3().optional()
4746147461
}).optional()
4746247462
});
47463+
var CONFIG_FILE_NAMES = [".git-branches.toml", ".git-town.toml"];
4746347464
var configFile;
47464-
try {
47465-
configFile = fs.readFileSync(".git-branches.toml").toString();
47466-
} catch {
47467-
configFile = void 0;
47468-
}
47465+
CONFIG_FILE_NAMES.forEach((file) => {
47466+
try {
47467+
configFile ??= fs.readFileSync(file).toString();
47468+
} catch {
47469+
configFile = void 0;
47470+
}
47471+
});
4746947472
var parsed = configSchema.safeParse(toml.parse(configFile ?? ""));
4747047473
if (!parsed.success) {
4747147474
core3.warning(
47472-
"Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml` is valid."
47475+
"Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml`/`.git-town.toml` is valid."
4747347476
);
4747447477
}
4747547478
var config = configFile && parsed.success ? parsed.data : void 0;

src/config.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ const configSchema = object({
1515

1616
export type Config = z.infer<typeof configSchema>
1717

18-
let configFile
19-
20-
try {
21-
configFile = fs.readFileSync('.git-branches.toml').toString()
22-
} catch {
23-
configFile = undefined
24-
}
18+
const CONFIG_FILE_NAMES = ['.git-branches.toml', '.git-town.toml']
19+
let configFile: string | undefined
20+
21+
CONFIG_FILE_NAMES.forEach((file) => {
22+
try {
23+
configFile ??= fs.readFileSync(file).toString()
24+
} catch {
25+
configFile = undefined
26+
}
27+
})
2528

2629
const parsed = configSchema.safeParse(toml.parse(configFile ?? ''))
2730

2831
if (!parsed.success) {
2932
core.warning(
30-
'Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml` is valid.'
33+
'Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml`/`.git-town.toml` is valid.'
3134
)
3235
}
3336

0 commit comments

Comments
 (0)