nodexh 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/main.js +11 -5
- package/lib/main.js.map +2 -2
- package/package.json +2 -3
- package/src/main.coffee +9 -3
package/lib/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
'use strict';
|
|
3
|
-
var FS, GUY, PATH, _exit_handler, _get_context, alert, bold, cyan, debug, echo, exit_handler, fetch_mapped_location, get_context, get_error_callsites, gold, green, grey, inspect, load_source_map, log, red, reverse, rpr, show_error_with_source_context, steel, underline, white, write_to_stderr, yellow;
|
|
3
|
+
var FS, GUY, PATH, _exit_handler, _get_context, alert, blue, bold, cyan, debug, echo, exit_handler, fetch_mapped_location, get_context, get_error_callsites, gold, green, grey, inspect, load_source_map, log, red, reverse, rpr, show_error_with_source_context, steel, underline, white, write_to_stderr, yellow;
|
|
4
4
|
|
|
5
5
|
//###########################################################################################################
|
|
6
6
|
GUY = require('guy');
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
PATH = require('path');
|
|
19
19
|
|
|
20
|
-
({red, green, steel, grey, cyan, bold, gold, white, yellow, reverse, underline, bold} = GUY.trm);
|
|
20
|
+
({red, green, steel, grey, cyan, bold, gold, white, blue, yellow, reverse, underline, bold} = GUY.trm); // Слава Україні // Слава Україні
|
|
21
21
|
|
|
22
22
|
//-----------------------------------------------------------------------------------------------------------
|
|
23
23
|
write_to_stderr = function(...P) {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
//-----------------------------------------------------------------------------------------------------------
|
|
106
106
|
show_error_with_source_context = async function(error, headline) {
|
|
107
107
|
/* TAINT use proper methods to format with multiple colors */
|
|
108
|
-
var arrowhead, arrowshaft, callsite, callsites, colnr, context_line, fname, fname_txt, i, j, len, len1, linenr, path, ref, ref1, ref2, relpath, width, width1;
|
|
108
|
+
var arrowhead, arrowshaft, callsite, callsites, colnr, context_line, fname, fname_txt, i, j, len, len1, linenr, path, path_color, ref, ref1, ref2, relpath, width, width1;
|
|
109
109
|
alert('^77765-1^', reverse(bold(headline)));
|
|
110
110
|
arrowhead = white('▲');
|
|
111
111
|
arrowshaft = white('│');
|
|
@@ -137,15 +137,21 @@
|
|
|
137
137
|
continue;
|
|
138
138
|
}
|
|
139
139
|
//.......................................................................................................
|
|
140
|
+
if (/\/node_modules\//.test(path)) {
|
|
141
|
+
path_color = yellow;
|
|
142
|
+
} else {
|
|
143
|
+
path_color = gold;
|
|
144
|
+
}
|
|
145
|
+
//.......................................................................................................
|
|
140
146
|
fname = (ref = (ref1 = callsite.getFunctionName()) != null ? ref1 : callsite.getMethodName()) != null ? ref : null;
|
|
141
147
|
({path, linenr, colnr} = (await fetch_mapped_location(path, linenr, colnr)));
|
|
142
148
|
relpath = PATH.relative(process.cwd(), path);
|
|
143
149
|
if (fname != null) {
|
|
144
150
|
fname_txt = steel(fname);
|
|
145
151
|
width1 = width + (fname_txt.length - fname.length);
|
|
146
|
-
write_to_stderr(arrowhead,
|
|
152
|
+
write_to_stderr(arrowhead, path_color(`${relpath} @ ${linenr},${colnr}: ${fname_txt}() \x1b[38;05;234m`.padEnd(width1, '—')));
|
|
147
153
|
} else {
|
|
148
|
-
write_to_stderr(arrowhead,
|
|
154
|
+
write_to_stderr(arrowhead, path_color(`${relpath} @ ${linenr},${colnr}: \x1b[38;05;234m`.padEnd(width, '—')));
|
|
149
155
|
}
|
|
150
156
|
ref2 = (await get_context(path, linenr, colnr, width));
|
|
151
157
|
for (j = 0, len1 = ref2.length; j < len1; j++) {
|
package/lib/main.js.map
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"../src/main.coffee"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AACA;EAAA;AAAA,MAAA,EAAA,EAAA,GAAA,EAAA,IAAA,EAAA,aAAA,EAAA,YAAA,EAAA,KAAA,EAAA,IA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nB;AACA,WAAO;EAhDwB,EAlFjC;;;EAqIA,aAAA,GAAgB,MAAA,QAAA,CAAE,KAAF,EAAS,MAAT,CAAA,EAAA;;AAChB,QAAA,OAAA,EAAA,GAAA,EAAA,IAAA,EAAA,IAAA,EAAA;IACE,IAAA,2EAAoC;IACpC,OAAA,GAAU,EAAA,CAAA,CAAI,IAAJ,CAAA,EAAA,CAAA,GAAe,kEAAmB,qCAAnB;IACzB,MAAM,8BAAA,CAA+B,KAA/B,EAAsC,OAAtC;AACN,WAAO;EALO,EArIhB;;;EA6IA,YAAA,GAAe,MAAA,QAAA,CAAE,KAAF,EAAS,MAAT,CAAA;IACb,MAAM,aAAA,CAAc,KAAd,EAAqB,MAArB;IACN,YAAA,CAAa,CAAE,QAAA,CAAA,CAAA;aAAG,OAAO,CAAC,IAAR,CAAa,GAAb;IAAH,CAAF,CAAb;AACA,WAAO;EAHM,EA7If;;;EAqJA,IAAO,mDAAP;IACE;IACA,MAAM,CAAE,MAAM,CAAC,GAAP,CAAW,uBAAX,CAAF,CAAN,GAA+C;IAC/C,OAAO,CAAC,IAAR,CAAa,mBAAb,EAAmC,YAAnC;IACA,OAAO,CAAC,IAAR,CAAa,oBAAb,EAAmC,YAAnC,EAJF;GArJA;;;EA6JA,MAAM,CAAC,OAAP,GAAiB,CAAE,YAAF,EAAgB,aAAhB;AA7JjB",
|
|
10
10
|
"sourcesContent": [
|
|
11
|
-
"\n'use strict'\n\n\n############################################################################################################\nGUY = require 'guy'\n{ alert\n debug } = GUY.trm.get_loggers 'NODEXH'\n{ rpr\n inspect\n echo\n log } = GUY.trm\nget_error_callsites = require 'error-callsites'\nload_source_map = ( require 'util' ).promisify ( require 'load-source-map' )\nFS = require 'fs'\nPATH = require 'path'\n{ red\n green\n steel\n grey\n cyan\n bold\n gold\n white\n yellow
|
|
11
|
+
"\n'use strict'\n\n\n############################################################################################################\nGUY = require 'guy'\n{ alert\n debug } = GUY.trm.get_loggers 'NODEXH'\n{ rpr\n inspect\n echo\n log } = GUY.trm\nget_error_callsites = require 'error-callsites'\nload_source_map = ( require 'util' ).promisify ( require 'load-source-map' )\nFS = require 'fs'\nPATH = require 'path'\n{ red\n green\n steel\n grey\n cyan\n bold\n gold\n white\n blue # Слава Україні\n yellow # Слава Україні\n reverse\n underline\n bold } = GUY.trm\n\n#-----------------------------------------------------------------------------------------------------------\nwrite_to_stderr = ( P... ) -> process.stderr.write ' ' + ( GUY.trm.pen P... ) + '\\n'\n\n#-----------------------------------------------------------------------------------------------------------\nfetch_mapped_location = ( path, linenr, colnr ) ->\n try\n sourcemap = await load_source_map path\n smp = sourcemap.originalPositionFor { line: linenr, column: colnr, }\n catch error\n return { path, linenr, colnr, }\n #.........................................................................................................\n if ( smp? ) and ( smp.source? ) and ( smp.source isnt '' ) and ( smp.line? ) and ( smp.column? )\n mapped_path = PATH.join ( PATH.dirname path ), smp.source\n return { path: mapped_path, linenr: smp.line, colnr: smp.column, }\n #.........................................................................................................\n return { path, linenr, colnr, }\n\n#-----------------------------------------------------------------------------------------------------------\nget_context = ( path, linenr, colnr, width ) ->\n try return ( _get_context path, linenr, colnr, width ) catch error\n throw error unless error.code is 'ENOENT'\n return []\n\n#-----------------------------------------------------------------------------------------------------------\n_get_context = ( path, linenr, colnr, width ) ->\n lines = ( FS.readFileSync path, { encoding: 'utf-8' } ).split '\\n'\n delta = 1\n coldelta = 5\n effect = reverse\n first_idx = Math.max 0, linenr - 1 - delta\n last_idx = Math.min lines.length - 1, linenr - 1 + delta\n R = []\n for line, idx in lines[ first_idx .. last_idx ]\n this_linenr = first_idx + idx + 1\n this_linenr_txt = ( this_linenr.toString().padStart 4 ) + '│ '\n if this_linenr isnt linenr\n ### TAINT should adjust overlong context lines as well ###\n R.push \"#{grey this_linenr_txt}#{grey line}\"\n continue\n ### TAINT perform line length adjustment, hiliting in dedicated method ###\n c0 = colnr - 1\n c1 = colnr + coldelta\n hilite = effect line[ c0 ... c1 ]\n line = line[ ... c0 ] + hilite + line[ c1 .. ]\n if c1 > width\n width2 = Math.floor width / 2\n line = '... ' + line[ c1 - width2 .. c1 + hilite.length - ( c1 - c0 ) + width2 ] + ' ...'\n else\n line = line[ .. width ]\n R.push \"#{grey this_linenr_txt}#{cyan line}\"\n return R\n\n#-----------------------------------------------------------------------------------------------------------\nshow_error_with_source_context = ( error, headline ) ->\n alert '^77765-1^', reverse bold headline\n arrowhead = white '▲'\n arrowshaft = white '│'\n width = process.stdout.columns\n callsites = get_error_callsites error\n #.........................................................................................................\n if ( not callsites? ) or ( callsites.length is 0 )\n write_to_stderr red reverse \"^455756^ error has no associated callsites:\"\n write_to_stderr red reverse rpr error\n return null\n #.........................................................................................................\n callsites.reverse()\n #.........................................................................................................\n for callsite in callsites\n path = callsite.getFileName()\n #.......................................................................................................\n unless path?\n write_to_stderr grey '—'.repeat 108\n continue\n #.......................................................................................................\n linenr = callsite.getLineNumber()\n colnr = callsite.getColumnNumber()\n #.......................................................................................................\n if ( path.startsWith 'node:internal/' ) or ( path.startsWith 'internal/' )\n write_to_stderr arrowhead, grey \"#{path} @ #{linenr},#{colnr}\"\n continue\n #.......................................................................................................\n if ( /\\/node_modules\\//.test path )\n path_color = yellow\n else\n path_color = gold\n #.......................................................................................................\n fname = callsite.getFunctionName() ? callsite.getMethodName() ? null\n { path\n linenr\n colnr } = await fetch_mapped_location path, linenr, colnr\n relpath = PATH.relative process.cwd(), path\n if fname?\n ### TAINT use proper methods to format with multiple colors ###\n fname_txt = steel fname\n width1 = width + ( fname_txt.length - fname.length )\n write_to_stderr arrowhead, path_color ( \"#{relpath} @ #{linenr},#{colnr}: #{fname_txt}() \\x1b[38;05;234m\".padEnd width1, '—' )\n else\n write_to_stderr arrowhead, path_color ( \"#{relpath} @ #{linenr},#{colnr}: \\x1b[38;05;234m\".padEnd width, '—' )\n for context_line in await get_context path, linenr, colnr, width\n write_to_stderr arrowshaft, context_line\n alert '^77765-2^', reverse bold headline\n return null\n\n#-----------------------------------------------------------------------------------------------------------\n_exit_handler = ( error, origin ) ->\n ### TAINT origin never used ###\n type = error.code ? error.name ? 'EXCEPTION'\n message = \" #{type}: \" + ( error?.message ? \"an unrecoverable condition occurred\" )\n await show_error_with_source_context error, message\n return null\n\n#-----------------------------------------------------------------------------------------------------------\nexit_handler = ( error, origin ) ->\n await _exit_handler error, origin\n setImmediate ( -> process.exit 111 )\n return null\n\n\n\n############################################################################################################\nunless global[ Symbol.for 'cnd-exception-handler' ]?\n null\n global[ Symbol.for 'cnd-exception-handler' ] = true\n process.once 'uncaughtException', exit_handler\n process.once 'unhandledRejection', exit_handler\n\n\n############################################################################################################\nmodule.exports = { exit_handler, _exit_handler, }\n\n"
|
|
12
12
|
]
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodexh",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "a wrapper around the `node` executable for better stacktraces with sourcemaps, sourcecode excerpts",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"error-callsites": "^2.0.3",
|
|
27
27
|
"guy": "^13.7.1",
|
|
28
|
-
"load-source-map": "3.0.1"
|
|
29
|
-
"stacktracey": "^2.0.14"
|
|
28
|
+
"load-source-map": "3.0.1"
|
|
30
29
|
},
|
|
31
30
|
"scripts": {
|
|
32
31
|
"build": "coffee --map -o lib -c src"
|
package/src/main.coffee
CHANGED
|
@@ -22,7 +22,8 @@ PATH = require 'path'
|
|
|
22
22
|
bold
|
|
23
23
|
gold
|
|
24
24
|
white
|
|
25
|
-
|
|
25
|
+
blue # Слава Україні
|
|
26
|
+
yellow # Слава Україні
|
|
26
27
|
reverse
|
|
27
28
|
underline
|
|
28
29
|
bold } = GUY.trm
|
|
@@ -108,6 +109,11 @@ show_error_with_source_context = ( error, headline ) ->
|
|
|
108
109
|
write_to_stderr arrowhead, grey "#{path} @ #{linenr},#{colnr}"
|
|
109
110
|
continue
|
|
110
111
|
#.......................................................................................................
|
|
112
|
+
if ( /\/node_modules\//.test path )
|
|
113
|
+
path_color = yellow
|
|
114
|
+
else
|
|
115
|
+
path_color = gold
|
|
116
|
+
#.......................................................................................................
|
|
111
117
|
fname = callsite.getFunctionName() ? callsite.getMethodName() ? null
|
|
112
118
|
{ path
|
|
113
119
|
linenr
|
|
@@ -117,9 +123,9 @@ show_error_with_source_context = ( error, headline ) ->
|
|
|
117
123
|
### TAINT use proper methods to format with multiple colors ###
|
|
118
124
|
fname_txt = steel fname
|
|
119
125
|
width1 = width + ( fname_txt.length - fname.length )
|
|
120
|
-
write_to_stderr arrowhead,
|
|
126
|
+
write_to_stderr arrowhead, path_color ( "#{relpath} @ #{linenr},#{colnr}: #{fname_txt}() \x1b[38;05;234m".padEnd width1, '—' )
|
|
121
127
|
else
|
|
122
|
-
write_to_stderr arrowhead,
|
|
128
|
+
write_to_stderr arrowhead, path_color ( "#{relpath} @ #{linenr},#{colnr}: \x1b[38;05;234m".padEnd width, '—' )
|
|
123
129
|
for context_line in await get_context path, linenr, colnr, width
|
|
124
130
|
write_to_stderr arrowshaft, context_line
|
|
125
131
|
alert '^77765-2^', reverse bold headline
|