Skip to content

Commit 2a1e22e

Browse files
committed
📦️Replace @colors/colors with picocolors
This fixes an extremely rare bug (that would break a future commit): DABH/colors.js#31
1 parent 6caf646 commit 2a1e22e

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

package-lock.json

+18-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
},
3232
"prettier": "./config/.prettierrc.js",
3333
"dependencies": {
34-
"@colors/colors": "^1.5.0",
3534
"dotenv": "^16.0.3",
3635
"fs-extra": "^10.1.0",
37-
"ms": "^2.1.3"
36+
"ms": "^2.1.3",
37+
"picocolors": "^1.0.0",
38+
"zod": "^3.19.1"
3839
},
3940
"devDependencies": {
4041
"@sucrase/jest-plugin": "^3.0.0",

src/utils/assertType/index.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import colors from '@colors/colors';
1+
import pc from 'picocolors';
22

33
import { createError } from '~/utils/createError';
44
import { throwError } from '~/utils/throwError';
@@ -30,15 +30,15 @@ export function assertType<I extends KeyValuePair>(variable: I, expectedType: Al
3030
const { stackTrace, functionName, filePath, packageName } = createError(true);
3131

3232
let output = '';
33-
output += '\n' + colors.bold.red(packageName);
34-
output += '\n' + colors.white(`Function called from the file: ${colors.red(filePath)}`);
35-
output += '\n' + colors.white(`Function called: ${colors.yellow(functionName)}`);
36-
output += '\n' + colors.white(`Variable name: ${colors.green(key)}`);
37-
output += '\n' + colors.white(`Variable value: ${colors.blue(String(value))}`);
38-
output += '\n' + colors.white(`Variable type: ${colors.cyan(typeof value)}`);
39-
output += '\n' + colors.white(`Expected type: ${colors.magenta(expectedType)}`);
40-
output += '\n\n' + colors.gray(stackTrace);
41-
output += '\n\n' + colors.gray('This error was thrown by the assertType() function from @lawlzer/helpers.');
33+
output += `\n ${pc.white(pc.bold(packageName))}`;
34+
output += `\n ${pc.white(`Function called from the file: ${pc.red(filePath)}`)}`;
35+
output += `\n ${pc.white(`Function called: ${pc.yellow(functionName)}`)}`;
36+
output += `\n ${pc.white(`Variable name: ${pc.green(key)}`)}`;
37+
output += `\n ${pc.white(`Variable value: ${pc.blue(String(value))}`)}`;
38+
output += `\n ${pc.white(`Variable type: ${pc.cyan(typeof value)}`)}`;
39+
output += `\n ${pc.white(`Expected type: ${pc.magenta(expectedType)}`)}`;
40+
output += `\n\n' ${pc.gray(stackTrace)}`;
41+
output += `\n\n' ${pc.gray('This error was thrown by the assertType() function from @lawlzer/helpers.')}`;
4242

4343
throw output;
4444
}

src/utils/throwError/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import colors from '@colors/colors';
21
import fs from 'fs-extra';
32
import ms from 'ms';
43
import os from 'os';
54
import path from 'path';
5+
import pc from 'picocolors';
66

77
import { findPackageJsonPathFromInside } from '~/dev-utils/findPackageJson';
88
import { createError } from '~/utils/createError';
@@ -17,12 +17,12 @@ export function throwError(...message: string[]): never {
1717
stackTrace.split('\n').splice(1, 5); // Remove these lines, as they are for createError()
1818

1919
let output = '';
20-
output += '\n' + colors.bold.red(packageName);
21-
output += '\n' + colors.white(`Function called from the file: ${colors.blue(filePath)}`);
22-
output += '\n' + colors.white(`Function called: ${colors.cyan(functionName)}`);
23-
output += '\n' + colors.white(`You made the mistake: ${colors.magenta(message.join(' '))}`);
24-
output += '\n\n' + colors.gray(stackTrace);
25-
output += '\n\n' + colors.gray('This error was thrown by the throwError() function from @lawlzer/helpers.');
20+
output += '\n' + pc.red(pc.bold(packageName));
21+
output += '\n' + pc.white(`Function called from the file: ${pc.blue(filePath)}`);
22+
output += '\n' + pc.white(`Function called: ${pc.cyan(functionName)}`);
23+
output += '\n' + pc.white(`You made the mistake: ${pc.magenta(message.join(' '))}`);
24+
output += '\n\n' + pc.gray(stackTrace);
25+
output += '\n\n' + pc.gray('This error was thrown by the throwError() function from @lawlzer/helpers.');
2626

2727
throw output;
2828
}

0 commit comments

Comments
 (0)