crash-js 0.1.96 → 0.1.98

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/crash-js/crash-js CHANGED
@@ -28,37 +28,52 @@
28
28
  */
29
29
 
30
30
  const
31
- _utils =
32
- require(
33
- "./utils");
31
+ _utils =
32
+ require(
33
+ "./utils");
34
34
  const
35
- _argv_get =
36
- _utils._argv_get;
35
+ _argv_get =
36
+ _utils._argv_get;
37
37
  const
38
- _argv_url_get =
39
- _utils._argv_url_get;
38
+ _argv_url_get =
39
+ _utils._argv_url_get;
40
40
  const
41
- _process_exit_get =
42
- _utils._process_exit_get;
41
+ _child_process_spawn_get =
42
+ _utils._child_process_spawn_get;
43
43
  const
44
- _process_exit =
45
- _process_exit_get();
44
+ _spawn =
45
+ _child_process_spawn_get();
46
46
  const
47
- _process_cwd_get =
48
- _utils._process_cwd_get;
47
+ _process_exit_get =
48
+ _utils._process_exit_get;
49
49
  const
50
- _process_cwd =
51
- _process_cwd_get();
50
+ _process_exit =
51
+ _process_exit_get();
52
52
  const
53
- _pwd =
54
- _process_cwd;
53
+ _process_cwd_get =
54
+ _utils._process_cwd_get;
55
55
  const
56
- _yargv_get =
57
- _utils._yargv_get;
56
+ _process_cwd =
57
+ _process_cwd_get();
58
58
  const
59
- _fs_utils =
60
- require(
61
- "./fs-utils");
59
+ _pwd =
60
+ _process_cwd;
61
+ const
62
+ _yargv_get =
63
+ _utils._yargv_get;
64
+ const
65
+ _fs_utils =
66
+ require(
67
+ "./fs-utils");
68
+ const
69
+ _dirname =
70
+ _fs_utils._dirname;
71
+ const
72
+ _file_exists =
73
+ _fs_utils._file_exists;
74
+ const
75
+ _path_join =
76
+ _fs_utils._path_join;
62
77
  const
63
78
  _basename =
64
79
  _fs_utils._basename;
@@ -66,6 +81,14 @@ const
66
81
  _stat =
67
82
  _fs_utils._stat;
68
83
 
84
+ function
85
+ _globals() {
86
+ app_name =
87
+ "";
88
+ quiet =
89
+ "y";
90
+ }
91
+
69
92
  function
70
93
  _app_name_get() {
71
94
  let
@@ -78,14 +101,44 @@ function
78
101
 
79
102
  function
80
103
  _msg_template(
81
- _app_name,
82
- _type) {
83
- const
104
+ _type,
105
+ _app_name) {
106
+ let
107
+ _template;
108
+ if ( typeof(
109
+ _app_name) == "undefined" ||
110
+ _app_name == "" ) {
84
111
  _template =
85
- `[${_app_name}] ${_type}: {_msg}`
112
+ `${_type}: {_msg}`;
113
+ }
114
+ else if ( typeof(
115
+ _app_name) == "string" ||
116
+ _app_name != "" ) {
117
+ _template =
118
+ `[${_app_name}] ${_type}: {_msg}`;
119
+ }
86
120
  return _template;
87
121
  }
88
122
 
123
+ function
124
+ _msg_warning(
125
+ _msg) {
126
+ let
127
+ _out;
128
+ if ( quiet == "n" ) {
129
+ _template =
130
+ _msg_template(
131
+ "WARNING",
132
+ app_name);
133
+ _out =
134
+ _template.replaceAll(
135
+ "{_msg}",
136
+ _msg);
137
+ console.warn(
138
+ _out);
139
+ }
140
+ }
141
+
89
142
  function
90
143
  _msg_info(
91
144
  _msg) {
@@ -94,8 +147,8 @@ function
94
147
  if ( quiet == "n" ) {
95
148
  _template =
96
149
  _msg_template(
97
- app_name,
98
- 'INFO');
150
+ "INFO",
151
+ app_name);
99
152
  _out =
100
153
  _template.replaceAll(
101
154
  "{_msg}",
@@ -112,23 +165,36 @@ function
112
165
  let
113
166
  _template,
114
167
  _out;
168
+ if ( typeof(
169
+ app_name) == "undefined" ||
170
+ app_name == "" ) {
171
+ const
172
+ app_name =
173
+ "";
174
+ }
115
175
  _exit =
116
176
  String(
117
177
  _exit);
178
+ console.log(
179
+ app_name);
118
180
  _template =
119
181
  _msg_template(
120
- app_name,
121
- 'ERROR');
182
+ "ERROR",
183
+ app_name);
122
184
  _out =
123
185
  _template.replaceAll(
124
186
  "{_msg}",
125
187
  _msg);
126
- console.error(
127
- _out);
128
188
  if ( _exit === "1" ) {
189
+ console.error(
190
+ _out);
129
191
  _process_exit(
130
192
  1);
131
193
  }
194
+ else if ( _exit === "0" ) {
195
+ console.warn(
196
+ _out);
197
+ }
132
198
  }
133
199
 
134
200
  function
@@ -286,10 +352,15 @@ function
286
352
  return _home;
287
353
  }
288
354
 
289
- function
355
+ async function
290
356
  _lib_get() {
291
357
  let
292
- _lib;
358
+ _lib,
359
+ _lib_path,
360
+ _line,
361
+ _out,
362
+ _path,
363
+ _words;
293
364
  if ( typeof window === 'undefined' &&
294
365
  ( typeof global !== 'undefined' && global.global === global ) &&
295
366
  typeof __webpack_require__ !== 'function' ) {
@@ -300,12 +371,52 @@ function
300
371
  "Environment variable NODE_PATH undefined.";
301
372
  _msg_info(
302
373
  _msg);
374
+ _lib =
375
+ ""
303
376
  }
304
377
  else {
378
+ const
379
+ _paths =
380
+ new Set();
305
381
  _lib =
306
382
  _path_join(
307
383
  [ process.env.NODE_PATH,
308
- ".." ]);
384
+ "../lib" ]);
385
+ if ( _file_exists(
386
+ _lib) ) {
387
+ _paths.add(
388
+ _lib);
389
+ return _lib;
390
+ }
391
+ else if ( ! _file_exists(
392
+ _lib) ) {
393
+ const
394
+ _out =
395
+ _run(
396
+ "sync",
397
+ [ "ldconfig",
398
+ "-p" ]);
399
+ const
400
+ _tail =
401
+ _out.slice(
402
+ 1,
403
+ _out.length - 2);
404
+ for ( _line of _tail ) {
405
+ _words =
406
+ _line.split(" ");
407
+ _lib_path =
408
+ _words[
409
+ 3];
410
+ _lib =
411
+ _dirname(
412
+ _lib_path);
413
+ _paths.add(
414
+ _lib);
415
+ }
416
+ for ( _path of _paths) {
417
+ return _path
418
+ }
419
+ }
309
420
  }
310
421
  }
311
422
  else {
@@ -341,11 +452,12 @@ function
341
452
  if ( _length < 0 ) {
342
453
  _msg =
343
454
  `Second argument 'end' ` +
344
- `must be greater than first ` +
345
- `argument 'start'.`;
346
- _msg_error(
347
- _msg,
348
- 1);
455
+ `is greater than first ` +
456
+ `argument 'start', returning ` +
457
+ `empty list.`;
458
+ _msg_warning(
459
+ _msg);
460
+ return [];
349
461
  }
350
462
  return Array(
351
463
  _length).keys().map(
@@ -353,6 +465,118 @@ function
353
465
  _index + _start);
354
466
  }
355
467
 
468
+ function
469
+ _run(
470
+ _run_mode,
471
+ _cmd) {
472
+ let
473
+ _index,
474
+ _msg;
475
+ if ( typeof(
476
+ _cmd) == "undefined" ||
477
+ _cmd == "" ||
478
+ _cmd == [] ) {
479
+ _msg =
480
+ "No command given in input.";
481
+ _msg_error(
482
+ _msg,
483
+ 1);
484
+ }
485
+ if ( typeof(
486
+ _run_mode) == "undefined" ||
487
+ _run_mode == "" ) {
488
+ _run_mode =
489
+ "sync";
490
+ }
491
+ const
492
+ _args =
493
+ [];
494
+ const
495
+ _program =
496
+ _cmd[
497
+ 0];
498
+ const
499
+ _indexes =
500
+ _seq(
501
+ 1,
502
+ _cmd.length - 1);
503
+ for ( _index of _indexes ) {
504
+ _args.push(
505
+ _cmd[
506
+ _index]);
507
+ }
508
+ _msg =
509
+ `Running '${_program}' ` +
510
+ `with arguments '${_args}'.`;
511
+ _msg_info(
512
+ _msg);
513
+ _out =
514
+ "";
515
+ if ( _run_mode == "async" ) {
516
+ const
517
+ _print =
518
+ function
519
+ (_data) {
520
+ _out =
521
+ _out +
522
+ _data.toString();
523
+ };
524
+ const
525
+ _close =
526
+ function(
527
+ _code) {
528
+ let
529
+ _array,
530
+ _msg;
531
+ if ( _code != 0 ) {
532
+ _msg =
533
+ `Process exited with code '${_code}'`;
534
+ _msg_error(
535
+ _msg,
536
+ 1);
537
+ }
538
+ else {
539
+ _msg =
540
+ `Process exited normally.`;
541
+ _msg_info(
542
+ _msg);
543
+ }
544
+ _array =
545
+ _out.split("\n");
546
+ return _array;
547
+ };
548
+ const
549
+ _process =
550
+ _spawn(
551
+ _program,
552
+ _args);
553
+ _process.stdout.on(
554
+ 'data',
555
+ _print);
556
+ _process.on(
557
+ 'close',
558
+ _close);
559
+ _array =
560
+ _out.split("\n");
561
+ _msg_info(
562
+ _array.length);
563
+ return _array;
564
+ }
565
+ else if ( _run_mode == "sync" ) {
566
+ const
567
+ _process =
568
+ _spawn(
569
+ _program,
570
+ _args,
571
+ { "encoding":
572
+ "utf-8" });
573
+ _array =
574
+ _process.stdout.split(
575
+ "\n");
576
+ return _array;
577
+ }
578
+ }
579
+
356
580
  function
357
581
  _seq(
358
582
  _start,
@@ -360,17 +584,18 @@ function
360
584
  let
361
585
  _item,
362
586
  _list;
363
- if ( _end < start ) {
587
+ _list =
588
+ [];
589
+ if ( _end < _start ) {
364
590
  _msg =
365
591
  `Second argument 'end' ` +
366
- `must be greater than first ` +
367
- `argument 'start'.`;
368
- _msg_error(
369
- _msg,
370
- 1);
592
+ `is greater than first ` +
593
+ `argument 'start', returning ` +
594
+ `empty list.`;
595
+ _msg_warning(
596
+ _msg);
597
+ return _list;
371
598
  }
372
- _list =
373
- [];
374
599
  if ( typeof(
375
600
  _end) === 'undefined' ) {
376
601
  _end =
@@ -410,7 +635,7 @@ module.exports = {
410
635
  _cmdline_check:
411
636
  _cmdline_check,
412
637
  _dirname:
413
- _fs_utils._dirname,
638
+ _dirname,
414
639
  _echo:
415
640
  _echo,
416
641
  _error_display:
@@ -429,6 +654,8 @@ module.exports = {
429
654
  _fs_utils._fs_worker_start,
430
655
  _get_date_human:
431
656
  _get_date_human,
657
+ _globals:
658
+ _globals,
432
659
  _homedir_get:
433
660
  _homedir_get,
434
661
  _json_display:
@@ -445,12 +672,14 @@ module.exports = {
445
672
  _msg_info,
446
673
  _msg_error:
447
674
  _msg_error,
675
+ _msg_warning:
676
+ _msg_warning,
448
677
  _msg_info_obj:
449
678
  _msg_info_obj,
450
679
  _mv:
451
680
  _fs_utils._mv,
452
681
  _path_join:
453
- _fs_utils._path_join,
682
+ _path_join,
454
683
  _printf:
455
684
  _printf,
456
685
  _process_exit:
@@ -463,6 +692,8 @@ module.exports = {
463
692
  _range,
464
693
  _rm:
465
694
  _fs_utils._rm,
695
+ _run:
696
+ _run,
466
697
  _seq:
467
698
  _seq,
468
699
  _sleep:
package/crash-js/utils CHANGED
@@ -104,25 +104,23 @@ function
104
104
 
105
105
  function
106
106
  _yargv_get() {
107
- let
108
- _argv,
109
- _hide_bin,
110
- _yargs,
111
- _yargs_object;
112
107
  if ( typeof window === 'undefined' &&
113
108
  ( typeof global !== 'undefined' && global.global === global ) ) {
114
- _yargs =
115
- require(
116
- "yargs");
109
+ const
110
+ _yargs =
111
+ require(
112
+ "yargs");
117
113
  _yargs_helpers_module =
118
114
  require(
119
115
  "yargs/helpers");
120
- _hide_bin =
121
- _yargs_helpers_module.hideBin;
122
- _yargs_object =
123
- _yargs(
124
- _hide_bin(
125
- process.argv));
116
+ const
117
+ _hide_bin =
118
+ _yargs_helpers_module.hideBin;
119
+ const
120
+ _yargs_object =
121
+ _yargs(
122
+ _hide_bin(
123
+ process.argv));
126
124
  return _yargs_object.parse();
127
125
  }
128
126
  }
@@ -165,7 +163,31 @@ function
165
163
  return ".";
166
164
  };
167
165
  }
168
- return _process_cwd
166
+ return _process_cwd;
167
+ }
168
+
169
+ function
170
+ _child_process_spawn_get() {
171
+ let
172
+ _child_process_spawn;
173
+ if ( typeof window === 'undefined' &&
174
+ ( typeof global !== 'undefined' && global.global === global ) &&
175
+ typeof __webpack_require__ !== 'function' ) {
176
+ const
177
+ _child_process_module =
178
+ require(
179
+ "node:child_process");
180
+ _child_process_spawn =
181
+ _child_process_module.spawnSync;
182
+ }
183
+ else {
184
+ _child_process_spawn =
185
+ function
186
+ (_cmd, _args, _exit) {
187
+ return _exit;
188
+ };
189
+ }
190
+ return _child_process_spawn;
169
191
  }
170
192
 
171
193
  module.exports = {
@@ -173,6 +195,8 @@ module.exports = {
173
195
  _argv_get,
174
196
  _argv_url_get:
175
197
  _argv_url_get,
198
+ _child_process_spawn_get:
199
+ _child_process_spawn_get,
176
200
  _process_exit_get:
177
201
  _process_exit_get,
178
202
  _process_cwd_get: