@clerc/core 0.42.1 → 0.42.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/dist/index.js +23 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -271,7 +271,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
271
271
|
__accessCheck(obj, member, "access private method");
|
|
272
272
|
return method;
|
|
273
273
|
};
|
|
274
|
-
var _name, _scriptName, _description, _version, _inspectors, _commands, _commandEmitter, _flags, _usedNames, _argv, _errorHandlers, _isOtherMethodCalled, _defaultLocale, _locale, _locales, _hasRootOrAlias, hasRootOrAlias_get, _hasRoot, hasRoot_get, _addCoreLocales, addCoreLocales_fn, _otherMethodCalled, otherMethodCalled_fn, _command, command_fn, _validateMeta, validateMeta_fn, _getContext, getContext_fn, _callWithErrorHandling, callWithErrorHandling_fn, _runMatchedCommand, runMatchedCommand_fn;
|
|
274
|
+
var _name, _scriptName, _description, _version, _inspectors, _commands, _commandEmitter, _flags, _usedNames, _argv, _errorHandlers, _isOtherMethodCalled, _defaultLocale, _locale, _locales, _hasRootOrAlias, hasRootOrAlias_get, _hasRoot, hasRoot_get, _addCoreLocales, addCoreLocales_fn, _otherMethodCalled, otherMethodCalled_fn, _command, command_fn, _validateMeta, validateMeta_fn, _getContext, getContext_fn, _handleError, handleError_fn, _callWithErrorHandling, callWithErrorHandling_fn, _runMatchedCommand, runMatchedCommand_fn;
|
|
275
275
|
const Root = Symbol.for("Clerc.Root");
|
|
276
276
|
const _Clerc = class {
|
|
277
277
|
constructor(scriptName, description, version) {
|
|
@@ -282,6 +282,7 @@ const _Clerc = class {
|
|
|
282
282
|
__privateAdd(this, _command);
|
|
283
283
|
__privateAdd(this, _validateMeta);
|
|
284
284
|
__privateAdd(this, _getContext);
|
|
285
|
+
__privateAdd(this, _handleError);
|
|
285
286
|
__privateAdd(this, _callWithErrorHandling);
|
|
286
287
|
__privateAdd(this, _runMatchedCommand);
|
|
287
288
|
__privateAdd(this, _name, "");
|
|
@@ -290,7 +291,11 @@ const _Clerc = class {
|
|
|
290
291
|
__privateAdd(this, _version, "");
|
|
291
292
|
__privateAdd(this, _inspectors, []);
|
|
292
293
|
__privateAdd(this, _commands, /* @__PURE__ */ Object.create(null));
|
|
293
|
-
__privateAdd(this, _commandEmitter, new LiteEmit(
|
|
294
|
+
__privateAdd(this, _commandEmitter, new LiteEmit({
|
|
295
|
+
errorHandler: (msg) => {
|
|
296
|
+
__privateMethod(this, _handleError, handleError_fn).call(this, new Error(msg));
|
|
297
|
+
}
|
|
298
|
+
}));
|
|
294
299
|
__privateAdd(this, _flags, /* @__PURE__ */ Object.create(null));
|
|
295
300
|
__privateAdd(this, _usedNames, /* @__PURE__ */ new Set());
|
|
296
301
|
__privateAdd(this, _argv, void 0);
|
|
@@ -744,18 +749,22 @@ getContext_fn = function(getCommand) {
|
|
|
744
749
|
};
|
|
745
750
|
return context;
|
|
746
751
|
};
|
|
752
|
+
_handleError = new WeakSet();
|
|
753
|
+
handleError_fn = function(e) {
|
|
754
|
+
if (__privateGet(this, _errorHandlers).length > 0) {
|
|
755
|
+
for (const cb of __privateGet(this, _errorHandlers)) {
|
|
756
|
+
cb(e);
|
|
757
|
+
}
|
|
758
|
+
} else {
|
|
759
|
+
throw e;
|
|
760
|
+
}
|
|
761
|
+
};
|
|
747
762
|
_callWithErrorHandling = new WeakSet();
|
|
748
763
|
callWithErrorHandling_fn = function(fn) {
|
|
749
764
|
try {
|
|
750
765
|
fn();
|
|
751
766
|
} catch (e) {
|
|
752
|
-
|
|
753
|
-
for (const cb of __privateGet(this, _errorHandlers)) {
|
|
754
|
-
cb(e);
|
|
755
|
-
}
|
|
756
|
-
} else {
|
|
757
|
-
throw e;
|
|
758
|
-
}
|
|
767
|
+
__privateMethod(this, _handleError, handleError_fn).call(this, e);
|
|
759
768
|
}
|
|
760
769
|
};
|
|
761
770
|
_runMatchedCommand = new WeakSet();
|
|
@@ -777,7 +786,11 @@ runMatchedCommand_fn = function() {
|
|
|
777
786
|
const error = stringName ? new NoSuchCommandError(stringName, t) : new NoCommandGivenError(t);
|
|
778
787
|
throw error;
|
|
779
788
|
}
|
|
780
|
-
|
|
789
|
+
try {
|
|
790
|
+
__privateGet(this, _commandEmitter).emit(command.name, ctx);
|
|
791
|
+
} catch (e) {
|
|
792
|
+
console.log(1);
|
|
793
|
+
}
|
|
781
794
|
}
|
|
782
795
|
};
|
|
783
796
|
const inspectors = [...__privateGet(this, _inspectors), emitHandler];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/core",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.2",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc core",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"defu": "^6.1.2",
|
|
51
51
|
"is-platform": "^1.0.0",
|
|
52
|
-
"lite-emit": "^2.
|
|
52
|
+
"lite-emit": "^2.3.0",
|
|
53
53
|
"type-fest": "^4.0.0",
|
|
54
54
|
"type-flag": "^3.0.0",
|
|
55
|
-
"@clerc/utils": "0.42.
|
|
55
|
+
"@clerc/utils": "0.42.2"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "pkgroll",
|