Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47460,16 +47460,19 @@ var configSchema = object({
"perennial-regex": string3().optional()
}).optional()
});
var CONFIG_FILE_NAMES = [".git-branches.toml", ".git-town.toml"];
var configFile;
try {
configFile = fs.readFileSync(".git-branches.toml").toString();
} catch {
configFile = void 0;
}
CONFIG_FILE_NAMES.forEach((file) => {
try {
configFile ??= fs.readFileSync(file).toString();
} catch {
configFile = void 0;
}
});
var parsed = configSchema.safeParse(toml.parse(configFile ?? ""));
if (!parsed.success) {
core3.warning(
"Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml` is valid."
"Failed to parse Git Town config. If this is a mistake, ensure that `.git-branches.toml`/`.git-town.toml` is valid."
);
}
var config = configFile && parsed.success ? parsed.data : void 0;
Expand Down
19 changes: 11 additions & 8 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ const configSchema = object({

export type Config = z.infer<typeof configSchema>

let configFile

try {
configFile = fs.readFileSync('.git-branches.toml').toString()
} catch {
configFile = undefined
}
const CONFIG_FILE_NAMES = ['.git-branches.toml', '.git-town.toml']
let configFile: string | undefined

CONFIG_FILE_NAMES.forEach((file) => {
try {
configFile ??= fs.readFileSync(file).toString()
} catch {
configFile = undefined
}
})

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

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

Expand Down
Loading