Skip to content

Commit

Permalink
feat(generate): add colors with the console.log
Browse files Browse the repository at this point in the history
Add colors with the console.log for the debug messages

Fixes #3

Signed-off-by: Niloy Sikdar <[email protected]>
  • Loading branch information
niloysikdar committed Oct 19, 2022
1 parent d375775 commit 23ef6cf
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type ArgsSchema = {
debug?: boolean;
};

const Colors = {
Reset: '\x1b[0m',
FgYellow: '\x1b[33m',
FgGreen: '\x1b[32m',
};

function _getArgs(): ArgsSchema {
const args: string[] = process.argv.slice(2);

Expand Down Expand Up @@ -84,7 +90,12 @@ function _generate({

if (js) {
for (const finalKey in parsedData) {
debug && console.log(`[JS] Generating for key: ${finalKey}`);
debug &&
console.log(
Colors.FgYellow,
`[JS] Generating for key: ${finalKey}`,
Colors.Reset,
);
envConfig = envConfig + ` ${finalKey}: process.env.${finalKey},\n`;
}

Expand All @@ -101,7 +112,12 @@ function _generate({
}
} else {
for (const finalKey in parsedData) {
debug && console.log(`[TS] Generating for key: ${finalKey}`);
debug &&
console.log(
Colors.FgYellow,
`[TS] Generating for key: ${finalKey}`,
Colors.Reset,
);
envConfig =
envConfig + ` ${finalKey}: String(process.env.${finalKey}),\n`;
}
Expand All @@ -116,7 +132,9 @@ function _generate({
writeFileSync(outPath, finalConfig);
debug &&
console.log(
Colors.FgGreen,
`${out ? out : defaultOutFile} has been generated successfully`,
Colors.Reset,
);
}

Expand Down

0 comments on commit 23ef6cf

Please sign in to comment.