nodexh 2.2.2 → 3.1.0
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/bin/nodexh +2 -0
- package/lib/main.js +13 -4
- package/lib/main.js.map +2 -2
- package/package.json +1 -1
- package/src/main.coffee +8 -4
package/bin/nodexh
CHANGED
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, 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;
|
|
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, lime, load_source_map, log, orange, other_path_color, own_path_color, 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,16 @@
|
|
|
17
17
|
|
|
18
18
|
PATH = require('path');
|
|
19
19
|
|
|
20
|
-
({red, green, steel, grey, cyan, bold, gold, white, blue, yellow, reverse, underline, bold} = GUY.trm); // Слава Україні // Слава Україні
|
|
20
|
+
({red, green, steel, grey, cyan, bold, lime, gold, white, orange, blue, yellow, reverse, underline, bold} = GUY.trm); // Слава Україні // Слава Україні
|
|
21
|
+
|
|
22
|
+
//-----------------------------------------------------------------------------------------------------------
|
|
23
|
+
other_path_color = function(...P) {
|
|
24
|
+
return reverse(bold(orange('', ...P, '')));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
own_path_color = function(...P) {
|
|
28
|
+
return reverse(bold(lime('', ...P, '')));
|
|
29
|
+
};
|
|
21
30
|
|
|
22
31
|
//-----------------------------------------------------------------------------------------------------------
|
|
23
32
|
write_to_stderr = function(...P) {
|
|
@@ -138,9 +147,9 @@
|
|
|
138
147
|
}
|
|
139
148
|
//.......................................................................................................
|
|
140
149
|
if (/\/node_modules\//.test(path)) {
|
|
141
|
-
path_color =
|
|
150
|
+
path_color = other_path_color;
|
|
142
151
|
} else {
|
|
143
|
-
path_color =
|
|
152
|
+
path_color = own_path_color;
|
|
144
153
|
}
|
|
145
154
|
//.......................................................................................................
|
|
146
155
|
fname = (ref = (ref1 = callsite.getFunctionName()) != null ? ref1 : callsite.getMethodName()) != null ? ref : null;
|
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,IAAA,EAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,qBAAA,EAAA,WAAA,EAAA,mBAAA,EAAA,IAAA,EAAA,KAAA,EAAA,IAAA,EAAA,OAAA,EAAA,eAAA,EAAA,GAAA,EAAA,GAAA,EAAA,OAAA,EAAA,GAAA,EAAA,8BAAA,EAAA,KAAA,EAAA,SAAA,EAAA,KAAA,EAAA,eAAA,EAAA,MAAA;;;EAIA,GAAA,GAA4B,OAAA,CAAQ,KAAR;;EAC5B,CAAA,CAAE,KAAF,EACE,KADF,CAAA,GAC4B,GAAG,CAAC,GAAG,CAAC,WAAR,CAAoB,QAApB,CAD5B;;EAEA,CAAA,CAAE,GAAF,EACE,OADF,EAEE,IAFF,EAGE,GAHF,CAAA,GAG4B,GAAG,CAAC,GAHhC;;EAIA,mBAAA,GAA4B,OAAA,CAAQ,iBAAR;;EAC5B,eAAA,GAA4B,CAAE,OAAA,CAAQ,MAAR,CAAF,CAAkB,CAAC,SAAnB,CAA+B,OAAA,CAA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B,qCAAnB;IACzB,MAAM,8BAAA,CAA+B,KAA/B,EAAsC,OAAtC;AACN,WAAO;EALO,EAzIhB;;;EAiJA,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,EAjJf;;;EAyJA,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;GAzJA;;;EAiKA,MAAM,CAAC,OAAP,GAAiB,CAAE,YAAF,EAAgB,aAAhB;AAjKjB",
|
|
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 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 )
|
|
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 lime\n gold\n white\n orange\n blue # Слава Україні\n yellow # Слава Україні\n reverse\n underline\n bold } = GUY.trm\n\n#-----------------------------------------------------------------------------------------------------------\nother_path_color = ( P... ) -> reverse bold orange '', P..., ''\nown_path_color = ( P... ) -> reverse bold lime '', P..., ''\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 ) then path_color = other_path_color\n else path_color = own_path_color\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
package/src/main.coffee
CHANGED
|
@@ -20,14 +20,20 @@ PATH = require 'path'
|
|
|
20
20
|
grey
|
|
21
21
|
cyan
|
|
22
22
|
bold
|
|
23
|
+
lime
|
|
23
24
|
gold
|
|
24
25
|
white
|
|
26
|
+
orange
|
|
25
27
|
blue # Слава Україні
|
|
26
28
|
yellow # Слава Україні
|
|
27
29
|
reverse
|
|
28
30
|
underline
|
|
29
31
|
bold } = GUY.trm
|
|
30
32
|
|
|
33
|
+
#-----------------------------------------------------------------------------------------------------------
|
|
34
|
+
other_path_color = ( P... ) -> reverse bold orange '', P..., ''
|
|
35
|
+
own_path_color = ( P... ) -> reverse bold lime '', P..., ''
|
|
36
|
+
|
|
31
37
|
#-----------------------------------------------------------------------------------------------------------
|
|
32
38
|
write_to_stderr = ( P... ) -> process.stderr.write ' ' + ( GUY.trm.pen P... ) + '\n'
|
|
33
39
|
|
|
@@ -109,10 +115,8 @@ show_error_with_source_context = ( error, headline ) ->
|
|
|
109
115
|
write_to_stderr arrowhead, grey "#{path} @ #{linenr},#{colnr}"
|
|
110
116
|
continue
|
|
111
117
|
#.......................................................................................................
|
|
112
|
-
if ( /\/node_modules\//.test path )
|
|
113
|
-
|
|
114
|
-
else
|
|
115
|
-
path_color = gold
|
|
118
|
+
if ( /\/node_modules\//.test path ) then path_color = other_path_color
|
|
119
|
+
else path_color = own_path_color
|
|
116
120
|
#.......................................................................................................
|
|
117
121
|
fname = callsite.getFunctionName() ? callsite.getMethodName() ? null
|
|
118
122
|
{ path
|