Skip to content

Commit 3c2572f

Browse files
committed
feat: add colors to error messages
1 parent 4fbe002 commit 3c2572f

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/main.ts

+29-10
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function main() {
9393
const token = process.env.WOKWI_CLI_TOKEN;
9494
if (token == null || token.length === 0) {
9595
console.error(
96-
`Error: Missing WOKWI_CLI_TOKEN environment variable. Please set it to your Wokwi token.\nGet your token at https://wokwi.com/dashboard/ci.`,
96+
chalkTemplate`{red Error:} Missing {yellow WOKWI_CLI_TOKEN} environment variable. Please set it to your Wokwi token.\nGet your token at {yellow https://wokwi.com/dashboard/ci.`,
9797
);
9898
process.exit(1);
9999
}
@@ -104,14 +104,24 @@ async function main() {
104104
const configExists = existsSync(configPath);
105105

106106
if (!elf && !configExists) {
107-
console.error(`Error: wokwi.toml not found in ${path.resolve(rootDir)}.`);
108-
console.error('Run `wokwi-cli init` to automatically create a wokwi.toml file.');
107+
console.error(
108+
chalkTemplate`{red Error:} {yellow wokwi.toml} not found in {yellow ${path.resolve(
109+
rootDir,
110+
)}}.`,
111+
);
112+
console.error(
113+
chalkTemplate`Run \`{green wokwi-cli init}\` to automatically create a {yellow wokwi.toml} file.`,
114+
);
109115
process.exit(1);
110116
}
111117

112118
if (!existsSync(diagramFilePath)) {
113-
console.error(`Error: diagram file not found in ${diagramFilePath}`);
114-
console.error('Run `wokwi-cli init` to automatically create a diagram.json file.');
119+
console.error(
120+
chalkTemplate`{red Error:} {yellow diagram.json} not found in {yellow ${diagramFilePath}}.`,
121+
);
122+
console.error(
123+
chalkTemplate`Run \`{green wokwi-cli init}\` to automatically create a {yellow diagram.json} file.`,
124+
);
115125
process.exit(1);
116126
}
117127

@@ -133,14 +143,22 @@ async function main() {
133143
}
134144

135145
if (!existsSync(firmwarePath)) {
136-
console.error(`Error: firmware file not found: ${path.resolve(firmwarePath)}`);
137-
console.error('Please check the firmware path in your wokwi.toml configuration file.');
146+
const fullPath = path.resolve(firmwarePath);
147+
console.error(
148+
chalkTemplate`{red Error:} {yellow firmware file} not found: {yellow ${fullPath}}.`,
149+
);
150+
console.error(
151+
chalkTemplate`Please check the {yellow firmware} path in your {yellow wokwi.toml} configuration file.`,
152+
);
138153
process.exit(1);
139154
}
140155

141156
if (!existsSync(elfPath)) {
142-
console.error(`Error: ELF file not found: ${path.resolve(elfPath)}`);
143-
console.error('Please check the ELF path in your wokwi.toml configuration file.');
157+
const fullPath = path.resolve(elfPath);
158+
console.error(chalkTemplate`{red Error:} ELF file not found: {yellow ${fullPath}}.`);
159+
console.error(
160+
chalkTemplate`Please check the {yellow elf} path in your {yellow wokwi.toml} configuration file.`,
161+
);
144162
process.exit(1);
145163
}
146164

@@ -150,7 +168,8 @@ async function main() {
150168

151169
const resolvedScenarioFile = scenarioFile ? path.resolve(rootDir, scenarioFile) : null;
152170
if (resolvedScenarioFile && !existsSync(resolvedScenarioFile)) {
153-
console.error(`Error: scenario file not found: ${path.resolve(resolvedScenarioFile)}`);
171+
const fullPath = path.resolve(resolvedScenarioFile);
172+
console.error(chalkTemplate`{red Error:} scenario file not found: {yellow ${fullPath}}.`);
154173
process.exit(1);
155174
}
156175

0 commit comments

Comments
 (0)