source-code-error
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "source-code-error", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Render Error of Source-Code", | ||
@@ -20,4 +20,4 @@ "keywords": [ "error", "code", "frame" ], | ||
"dependencies": { | ||
"@babel/code-frame": "7.12.11", | ||
"chalk": "4.1.0", | ||
"@babel/code-frame": "7.14.5", | ||
"chalk": "4.1.2", | ||
"strip-ansi": "6.0.0" | ||
@@ -27,6 +27,6 @@ }, | ||
"babel-eslint": "10.1.0", | ||
"eslint": "7.17.0", | ||
"eslint-config-standard": "16.0.2", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint": "7.32.0", | ||
"eslint-config-standard": "16.0.3", | ||
"eslint-plugin-promise": "5.1.0", | ||
"eslint-plugin-import": "2.24.2", | ||
"eslint-plugin-node": "11.1.0" | ||
@@ -33,0 +33,0 @@ }, |
@@ -19,1 +19,15 @@ | ||
frame = errorFrame({ | ||
type: "WARNING", | ||
message: "Unknown warning", | ||
origin: "somewhere", | ||
filename: "foo.txt", | ||
code: code, | ||
line: 2, | ||
column: 5, | ||
colors: true, | ||
newline: false | ||
}) | ||
console.log(frame) | ||
@@ -56,2 +56,5 @@ /* | ||
/* determine type related color */ | ||
const color = (options.type === "ERROR" ? "red" : "yellow") | ||
/* render code frame */ | ||
@@ -71,5 +74,5 @@ let frame = codeFrame(options.code, { start: { line: options.line, column: options.column } }, { | ||
.replace(/(\|\s*)(\^)/, (_, m1, m2) => | ||
chalk.grey(m1) + chalk.bold.red(m2)) | ||
chalk.grey(m1) + chalk[color].bold(m2)) | ||
.replace(/(\n)(>)(\s*\d+\s+\|)(.*)/, (_, m1, m2, m3, m4) => | ||
m1 + chalk.bold.red(m2) + chalk.grey(m3) + chalk.blue(m4)) | ||
m1 + chalk[color].bold(m2) + chalk.grey(m3) + chalk.blue(m4)) | ||
} | ||
@@ -79,10 +82,10 @@ | ||
let header = "" | ||
header += `${chalk.bold.red(options.type + ":")} ` | ||
header += `${chalk[color].bold(options.type + ":")} ` | ||
if (options.filename !== "") { | ||
const dirname = path.dirname(options.filename) + path.sep | ||
const basename = path.basename(options.filename) | ||
header += `${chalk.red("file \"")}${chalk.red(dirname)}${chalk.red.bold(basename)}${chalk.red("\", ")}` | ||
header += `${chalk[color]("file \"")}${chalk[color](dirname)}${chalk[color].bold(basename)}${chalk[color]("\", ")}` | ||
} | ||
header += `${chalk.red("line ")}${chalk.red.bold(options.line)}` + | ||
`${chalk.red(", column ")}${chalk.red.bold(options.column)}:\n` | ||
header += `${chalk[color]("line ")}${chalk[color].bold(options.line)}` + | ||
`${chalk[color](", column ")}${chalk[color].bold(options.column)}:\n` | ||
if (options.message !== "" || options.origin !== "") { | ||
@@ -89,0 +92,0 @@ header += " ".repeat(options.type.length + 2) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11817
121
+ Added@babel/code-frame@7.14.5(transitive)
+ Addedchalk@4.1.2(transitive)
- Removed@babel/code-frame@7.12.11(transitive)
- Removedchalk@4.1.0(transitive)
Updated@babel/code-frame@7.14.5
Updatedchalk@4.1.2