feat(config): allow RCZ configs to be located in a folder (#15)

This commit is contained in:
2023-12-17 18:19:09 +02:00
parent 4de93ef3e2
commit d707aaffe6
4 changed files with 46 additions and 10 deletions

View File

@@ -38,6 +38,50 @@ const GetConfig = async () => {
await fs.promises.readFile(path.join(process.cwd(), "rcz.config.json")) await fs.promises.readFile(path.join(process.cwd(), "rcz.config.json"))
).toString() ).toString()
) as Config; ) as Config;
} else if (fs.existsSync(path.join(process.cwd(), ".rcz", "config.json"))) {
return JSON.parse(
(
await fs.promises.readFile(
path.join(process.cwd(), ".rcz", "config.json")
)
).toString()
) as Config;
} else {
return null;
}
};
const GetOnReleaseScript = async () => {
if (fs.existsSync(path.join(process.cwd(), ".rcz.onrelease.js"))) {
return (
await fs.promises.readFile(path.join(process.cwd(), ".rcz.onrelease.js"))
).toString();
} else if (fs.existsSync(path.join(process.cwd(), ".rcz", "onrelease.js"))) {
return (
await fs.promises.readFile(
path.join(process.cwd(), ".rcz", "onrelease.js")
)
).toString();
} else {
return null;
}
};
const GetPostReleaseScript = async () => {
if (fs.existsSync(path.join(process.cwd(), ".rcz.postrelease.js"))) {
return (
await fs.promises.readFile(
path.join(process.cwd(), ".rcz.postrelease.js")
)
).toString();
} else if (
fs.existsSync(path.join(process.cwd(), ".rcz", "postrelease.js"))
) {
return (
await fs.promises.readFile(
path.join(process.cwd(), ".rcz", "postrelease.js")
)
).toString();
} else { } else {
return null; return null;
} }
@@ -501,11 +545,7 @@ program
const sign = config?.autoSignReleases || options.sign ? true : false; const sign = config?.autoSignReleases || options.sign ? true : false;
const version = string.replace("v", ""); const version = string.replace("v", "");
const onReleaseFile = ( const onReleaseFile = await GetOnReleaseScript();
await fs.promises.readFile(
path.join(process.cwd(), ".rczrc.onrelease.js")
)
).toString();
if (onReleaseFile) { if (onReleaseFile) {
const releaseScript = ` const releaseScript = `
@@ -542,11 +582,7 @@ program
: [`-a`, `v${version}`, `-m`, `"v${version}"`] : [`-a`, `v${version}`, `-m`, `"v${version}"`]
); );
const postReleaseFile = ( const postReleaseFile = await GetPostReleaseScript();
await fs.promises.readFile(
path.join(process.cwd(), ".rczrc.postrelease.js")
)
).toString();
if (postReleaseFile) { if (postReleaseFile) {
const postReleaseScript = ` const postReleaseScript = `