fix: incorrect config parsing
This commit is contained in:
14
src/index.ts
14
src/index.ts
@@ -16,9 +16,11 @@ import simpleGit from "simple-git";
|
||||
|
||||
const GetConfig = async () => {
|
||||
if (fs.existsSync(path.join(process.cwd(), ".rczrc"))) {
|
||||
return (await fs.promises.readFile(
|
||||
path.join(process.cwd(), ".rczrc")
|
||||
)) as Config;
|
||||
return JSON.parse(
|
||||
(
|
||||
await fs.promises.readFile(path.join(process.cwd(), ".rczrc"))
|
||||
).toString()
|
||||
) as Config;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -46,7 +48,7 @@ const GetConfig = async () => {
|
||||
|
||||
const type: string | symbol = await select({
|
||||
message: "Choose a commit type",
|
||||
options: [
|
||||
options: config?.types || [
|
||||
{
|
||||
label: "feat",
|
||||
value: "feat",
|
||||
@@ -93,7 +95,7 @@ const GetConfig = async () => {
|
||||
const scope: string | symbol = await text({
|
||||
message: "Input a scope (e.g. router, forms, core) or leave empty",
|
||||
validate: (value) => {
|
||||
if (config?.scopes) {
|
||||
if (config?.scopes && value) {
|
||||
if (!config?.scopes.includes(value))
|
||||
return "This scope is not allowed by local configuration";
|
||||
}
|
||||
@@ -120,7 +122,7 @@ const GetConfig = async () => {
|
||||
}
|
||||
|
||||
const body = await text({
|
||||
message: `Briefly describe made changes in imperative tense, recommended length 100, can be left empty`,
|
||||
message: `Insert a commit body, recommended length 100, can be left empty`,
|
||||
});
|
||||
|
||||
if (isCancel(body)) {
|
||||
|
||||
Reference in New Issue
Block a user