crash-js 0.1.107 → 0.1.110
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 +119 -48
- package/crash-js/utils +56 -21
- package/package.json +7 -1
package/crash-js/crash-js
CHANGED
|
@@ -29,45 +29,49 @@
|
|
|
29
29
|
|
|
30
30
|
const
|
|
31
31
|
_utils =
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
require(
|
|
33
|
+
"./utils");
|
|
34
34
|
const
|
|
35
35
|
_argv_get =
|
|
36
|
-
|
|
36
|
+
_utils._argv_get;
|
|
37
37
|
const
|
|
38
38
|
_argv_url_get =
|
|
39
|
-
|
|
39
|
+
_utils._argv_url_get;
|
|
40
40
|
const
|
|
41
41
|
_child_process_spawn_get =
|
|
42
|
-
|
|
42
|
+
_utils._child_process_spawn_get;
|
|
43
43
|
const
|
|
44
|
-
_spawn =
|
|
45
|
-
|
|
44
|
+
_spawn =
|
|
45
|
+
_child_process_spawn_get();
|
|
46
|
+
const
|
|
47
|
+
_spawn_async =
|
|
48
|
+
_child_process_spawn_get(
|
|
49
|
+
"async");
|
|
46
50
|
const
|
|
47
51
|
_process_exit_get =
|
|
48
|
-
|
|
52
|
+
_utils._process_exit_get;
|
|
49
53
|
const
|
|
50
54
|
_process_exit =
|
|
51
|
-
|
|
55
|
+
_process_exit_get();
|
|
52
56
|
const
|
|
53
57
|
_process_cwd_get =
|
|
54
|
-
|
|
58
|
+
_utils._process_cwd_get;
|
|
55
59
|
const
|
|
56
60
|
_process_cwd =
|
|
57
|
-
|
|
61
|
+
_process_cwd_get();
|
|
58
62
|
const
|
|
59
63
|
_pwd =
|
|
60
|
-
|
|
64
|
+
_process_cwd;
|
|
61
65
|
const
|
|
62
66
|
_yargv_get =
|
|
63
|
-
|
|
67
|
+
_utils._yargv_get;
|
|
64
68
|
const
|
|
65
69
|
_fs_utils =
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
require(
|
|
71
|
+
"./fs-utils");
|
|
68
72
|
const
|
|
69
73
|
_dirname =
|
|
70
|
-
|
|
74
|
+
_fs_utils._dirname;
|
|
71
75
|
const
|
|
72
76
|
_file_exists =
|
|
73
77
|
_fs_utils._file_exists;
|
|
@@ -465,13 +469,19 @@ function
|
|
|
465
469
|
_index + _start);
|
|
466
470
|
}
|
|
467
471
|
|
|
468
|
-
function
|
|
472
|
+
async function
|
|
469
473
|
_run(
|
|
470
474
|
_run_mode,
|
|
471
|
-
_cmd
|
|
475
|
+
_cmd,
|
|
476
|
+
_name,
|
|
477
|
+
_timeout,
|
|
478
|
+
_run_type,
|
|
479
|
+
_method) {
|
|
472
480
|
let
|
|
481
|
+
_array,
|
|
473
482
|
_index,
|
|
474
|
-
_msg
|
|
483
|
+
_msg,
|
|
484
|
+
_out;
|
|
475
485
|
if ( typeof(
|
|
476
486
|
_cmd) == "undefined" ||
|
|
477
487
|
_cmd == "" ||
|
|
@@ -482,28 +492,44 @@ function
|
|
|
482
492
|
_msg,
|
|
483
493
|
1);
|
|
484
494
|
}
|
|
485
|
-
if ( typeof(
|
|
486
|
-
_run_mode) == "undefined" ||
|
|
487
|
-
_run_mode == "" ) {
|
|
488
|
-
_run_mode =
|
|
489
|
-
"sync";
|
|
490
|
-
}
|
|
491
|
-
const
|
|
492
|
-
_args =
|
|
493
|
-
[];
|
|
494
495
|
const
|
|
495
496
|
_program =
|
|
496
497
|
_cmd[
|
|
497
498
|
0];
|
|
498
499
|
const
|
|
499
|
-
|
|
500
|
-
|
|
500
|
+
_args =
|
|
501
|
+
_cmd.slice(
|
|
501
502
|
1,
|
|
502
|
-
_cmd.length
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
503
|
+
_cmd.length);
|
|
504
|
+
if ( typeof(
|
|
505
|
+
_run_mode) == "undefined" ||
|
|
506
|
+
_run_mode == "" ) {
|
|
507
|
+
_run_mode =
|
|
508
|
+
"sync";
|
|
509
|
+
}
|
|
510
|
+
if ( typeof(
|
|
511
|
+
_name) == "undefined" ||
|
|
512
|
+
_name == "" ) {
|
|
513
|
+
_name =
|
|
514
|
+
"";
|
|
515
|
+
}
|
|
516
|
+
if ( typeof(
|
|
517
|
+
_timeout) == "undefined" ||
|
|
518
|
+
_timeout == "" ) {
|
|
519
|
+
_timeout =
|
|
520
|
+
"0";
|
|
521
|
+
}
|
|
522
|
+
if ( typeof(
|
|
523
|
+
_run_type) == "undefined" ||
|
|
524
|
+
_run_type == "" ) {
|
|
525
|
+
_run_type =
|
|
526
|
+
"spawn";
|
|
527
|
+
}
|
|
528
|
+
if ( typeof(
|
|
529
|
+
_method) == "undefined" ||
|
|
530
|
+
_method == "" ) {
|
|
531
|
+
_method =
|
|
532
|
+
"";
|
|
507
533
|
}
|
|
508
534
|
_msg =
|
|
509
535
|
`Running '${_program}' ` +
|
|
@@ -513,6 +539,7 @@ function
|
|
|
513
539
|
_out =
|
|
514
540
|
"";
|
|
515
541
|
if ( _run_mode == "async" ) {
|
|
542
|
+
// currently not working well id say
|
|
516
543
|
const
|
|
517
544
|
_print =
|
|
518
545
|
function
|
|
@@ -547,7 +574,7 @@ function
|
|
|
547
574
|
};
|
|
548
575
|
const
|
|
549
576
|
_process =
|
|
550
|
-
|
|
577
|
+
_spawn_async(
|
|
551
578
|
_program,
|
|
552
579
|
_args);
|
|
553
580
|
_process.stdout.on(
|
|
@@ -557,23 +584,67 @@ function
|
|
|
557
584
|
'close',
|
|
558
585
|
_close);
|
|
559
586
|
_array =
|
|
560
|
-
_out.split(
|
|
587
|
+
_out.split(
|
|
588
|
+
"\n");
|
|
561
589
|
_msg_info(
|
|
562
590
|
_array.length);
|
|
563
591
|
return _array;
|
|
564
592
|
}
|
|
565
593
|
else if ( _run_mode == "sync" ) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
594
|
+
if ( _run_type == "spawn" ) {
|
|
595
|
+
const
|
|
596
|
+
_process =
|
|
597
|
+
_spawn(
|
|
598
|
+
_program,
|
|
599
|
+
_args,
|
|
600
|
+
{ "encoding":
|
|
601
|
+
"utf-8" });
|
|
602
|
+
_array =
|
|
603
|
+
_process.stdout.split(
|
|
604
|
+
"\n");
|
|
605
|
+
return _array;
|
|
606
|
+
}
|
|
607
|
+
else if ( _run_type == "native" ) {
|
|
608
|
+
_msg_timeout =
|
|
609
|
+
`Timeout of length ` +
|
|
610
|
+
`'${_timeout}' ms reached for task '${_name}'.`;
|
|
611
|
+
_time_over =
|
|
612
|
+
false;
|
|
613
|
+
const
|
|
614
|
+
_exit_timeout =
|
|
615
|
+
() => {
|
|
616
|
+
throw _msg_timeout;
|
|
617
|
+
};
|
|
618
|
+
try {
|
|
619
|
+
setTimeout(
|
|
620
|
+
_exit_timeout,
|
|
621
|
+
_timeout);
|
|
622
|
+
if ( _method != "" ) {
|
|
623
|
+
_out =
|
|
624
|
+
await _program[
|
|
625
|
+
_method].apply(
|
|
626
|
+
_program,
|
|
627
|
+
_args);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
_out =
|
|
631
|
+
await _program.apply(
|
|
632
|
+
null,
|
|
633
|
+
_args);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
catch(
|
|
637
|
+
_error) {
|
|
638
|
+
_time_over =
|
|
639
|
+
true;
|
|
640
|
+
}
|
|
641
|
+
if ( _time_over ) {
|
|
642
|
+
throw _msg_timeout;
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
return _out;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
577
648
|
}
|
|
578
649
|
}
|
|
579
650
|
|
package/crash-js/utils
CHANGED
|
@@ -108,14 +108,20 @@ function
|
|
|
108
108
|
_yargv_get(
|
|
109
109
|
_args) {
|
|
110
110
|
let
|
|
111
|
-
_boolean
|
|
112
|
-
|
|
111
|
+
_boolean;
|
|
112
|
+
const
|
|
113
|
+
_yargs_opts =
|
|
114
|
+
{};
|
|
115
|
+
const
|
|
116
|
+
_parser_opts =
|
|
117
|
+
{};
|
|
113
118
|
if ( typeof(
|
|
114
119
|
_args) == "undefined" ||
|
|
115
120
|
_args == {} ||
|
|
116
121
|
_args == "" ) {
|
|
117
122
|
_args = {
|
|
118
|
-
"booleans": []
|
|
123
|
+
"booleans": [],
|
|
124
|
+
"string": true
|
|
119
125
|
};
|
|
120
126
|
}
|
|
121
127
|
const
|
|
@@ -134,11 +140,24 @@ function
|
|
|
134
140
|
const
|
|
135
141
|
_hide_bin =
|
|
136
142
|
_yargs_helpers_module.hideBin;
|
|
137
|
-
|
|
143
|
+
if ( "string" in _args &&
|
|
144
|
+
_args[
|
|
145
|
+
"string"] ) {
|
|
146
|
+
_yargs_opts[
|
|
147
|
+
"_"] = {
|
|
148
|
+
"type":
|
|
149
|
+
"string",
|
|
150
|
+
"string":
|
|
151
|
+
true
|
|
152
|
+
};
|
|
153
|
+
_parser_opts[
|
|
154
|
+
"parse-numbers"] =
|
|
155
|
+
false;
|
|
156
|
+
_parser_opts[
|
|
157
|
+
"parse-positional-numbers"] =
|
|
158
|
+
false;
|
|
159
|
+
}
|
|
138
160
|
if ( _booleans.length > 0 ) {
|
|
139
|
-
const
|
|
140
|
-
_yargs_opts =
|
|
141
|
-
{};
|
|
142
161
|
for ( _boolean of _booleans) {
|
|
143
162
|
_yargs_opts[
|
|
144
163
|
_boolean] = {
|
|
@@ -150,19 +169,22 @@ function
|
|
|
150
169
|
"boolean",
|
|
151
170
|
};
|
|
152
171
|
}
|
|
153
|
-
_yargs_object =
|
|
154
|
-
_yargs(
|
|
155
|
-
_hide_bin(
|
|
156
|
-
process.argv)).options(
|
|
157
|
-
_yargs_opts);
|
|
158
172
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
if ( 0 < _booleans.length ||
|
|
174
|
+
_args[
|
|
175
|
+
"string"] ) {
|
|
176
|
+
return _yargs(
|
|
177
|
+
_hide_bin(
|
|
178
|
+
process.argv)).parserConfiguration(
|
|
179
|
+
_parser_opts).options(
|
|
180
|
+
_yargs_opts).string(
|
|
181
|
+
"_").parse();
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return _yargs(
|
|
185
|
+
_hide_bin(
|
|
186
|
+
process.argv));
|
|
164
187
|
}
|
|
165
|
-
return _yargs_object.parse();
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
190
|
|
|
@@ -208,9 +230,16 @@ function
|
|
|
208
230
|
}
|
|
209
231
|
|
|
210
232
|
function
|
|
211
|
-
_child_process_spawn_get(
|
|
233
|
+
_child_process_spawn_get(
|
|
234
|
+
_spawn_type) {
|
|
212
235
|
let
|
|
213
236
|
_child_process_spawn;
|
|
237
|
+
if ( typeof(
|
|
238
|
+
_spawn_type) == "undefined" ||
|
|
239
|
+
_spawn_type == "" ) {
|
|
240
|
+
_spawn_type =
|
|
241
|
+
"sync";
|
|
242
|
+
}
|
|
214
243
|
if ( typeof window === 'undefined' &&
|
|
215
244
|
( typeof global !== 'undefined' && global.global === global ) &&
|
|
216
245
|
typeof __webpack_require__ !== 'function' ) {
|
|
@@ -218,8 +247,14 @@ function
|
|
|
218
247
|
_child_process_module =
|
|
219
248
|
require(
|
|
220
249
|
"node:child_process");
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
if ( _spawn_type == "sync" ) {
|
|
251
|
+
_child_process_spawn =
|
|
252
|
+
_child_process_module.spawnSync;
|
|
253
|
+
}
|
|
254
|
+
else if ( _spawn_type == "async" ) {
|
|
255
|
+
_child_process_spawn =
|
|
256
|
+
_child_process_module.spawn;
|
|
257
|
+
}
|
|
223
258
|
}
|
|
224
259
|
else {
|
|
225
260
|
_child_process_spawn =
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name":
|
|
3
3
|
"crash-js",
|
|
4
4
|
"version":
|
|
5
|
-
"0.1.
|
|
5
|
+
"0.1.110",
|
|
6
6
|
"description":
|
|
7
7
|
"Crash Javascript library.",
|
|
8
8
|
"funding":
|
|
@@ -77,6 +77,12 @@
|
|
|
77
77
|
"yargs":
|
|
78
78
|
"18.0.0"
|
|
79
79
|
},
|
|
80
|
+
"yargs": {
|
|
81
|
+
"parse-numbers":
|
|
82
|
+
false,
|
|
83
|
+
"parse-positionalnumbers":
|
|
84
|
+
false
|
|
85
|
+
},
|
|
80
86
|
"type":
|
|
81
87
|
"commonjs",
|
|
82
88
|
"main":
|