feat(config): allow RCZ configs to be located in a folder (#15)
This commit is contained in:
56
src/index.ts
56
src/index.ts
@@ -38,6 +38,50 @@ const GetConfig = async () => {
|
||||
await fs.promises.readFile(path.join(process.cwd(), "rcz.config.json"))
|
||||
).toString()
|
||||
) 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 {
|
||||
return null;
|
||||
}
|
||||
@@ -501,11 +545,7 @@ program
|
||||
const sign = config?.autoSignReleases || options.sign ? true : false;
|
||||
const version = string.replace("v", "");
|
||||
|
||||
const onReleaseFile = (
|
||||
await fs.promises.readFile(
|
||||
path.join(process.cwd(), ".rczrc.onrelease.js")
|
||||
)
|
||||
).toString();
|
||||
const onReleaseFile = await GetOnReleaseScript();
|
||||
|
||||
if (onReleaseFile) {
|
||||
const releaseScript = `
|
||||
@@ -542,11 +582,7 @@ program
|
||||
: [`-a`, `v${version}`, `-m`, `"v${version}"`]
|
||||
);
|
||||
|
||||
const postReleaseFile = (
|
||||
await fs.promises.readFile(
|
||||
path.join(process.cwd(), ".rczrc.postrelease.js")
|
||||
)
|
||||
).toString();
|
||||
const postReleaseFile = await GetPostReleaseScript();
|
||||
|
||||
if (postReleaseFile) {
|
||||
const postReleaseScript = `
|
||||
|
||||
Reference in New Issue
Block a user