kareem 2.4.0 → 2.4.1
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/.eslintrc.json +16 -0
- package/.github/workflows/test.yml +21 -4
- package/docs.js +2 -0
- package/index.js +9 -4
- package/package.json +4 -1
- package/test/examples.test.js +3 -0
- package/test/misc.test.js +1 -1
- package/test/post.test.js +1 -0
- package/test/pre.test.js +1 -0
- package/test/wrap.test.js +3 -0
- package/gulpfile.js +0 -18
package/.eslintrc.json
ADDED
|
@@ -13,9 +13,6 @@ jobs:
|
|
|
13
13
|
matrix:
|
|
14
14
|
node: [12, 14, 16, 18]
|
|
15
15
|
os: [ubuntu-20.04]
|
|
16
|
-
include:
|
|
17
|
-
- os: ubuntu-20.04
|
|
18
|
-
mongo-os: ubuntu2004
|
|
19
16
|
name: Node ${{ matrix.node }}
|
|
20
17
|
steps:
|
|
21
18
|
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3
|
|
@@ -27,4 +24,24 @@ jobs:
|
|
|
27
24
|
|
|
28
25
|
- run: npm install
|
|
29
26
|
|
|
30
|
-
- run: npm test
|
|
27
|
+
- run: npm test
|
|
28
|
+
|
|
29
|
+
lint:
|
|
30
|
+
runs-on: ${{ matrix.os }}
|
|
31
|
+
strategy:
|
|
32
|
+
fail-fast: false
|
|
33
|
+
matrix:
|
|
34
|
+
node: [18]
|
|
35
|
+
os: [ubuntu-20.04]
|
|
36
|
+
name: Lint
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3
|
|
39
|
+
|
|
40
|
+
- name: Setup node
|
|
41
|
+
uses: actions/setup-node@5b52f097d36d4b0b2f94ed6de710023fbb8b2236 # v3.1.0
|
|
42
|
+
with:
|
|
43
|
+
node-version: ${{ matrix.node }}
|
|
44
|
+
|
|
45
|
+
- run: npm install
|
|
46
|
+
|
|
47
|
+
- run: npm run lint
|
package/docs.js
CHANGED
package/index.js
CHANGED
|
@@ -242,7 +242,12 @@ Kareem.prototype.execPost = function(name, context, args, options, callback) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
if (isPromiseLike(maybePromiseLike)) {
|
|
245
|
-
return maybePromiseLike.then(
|
|
245
|
+
return maybePromiseLike.then(
|
|
246
|
+
(res) => {
|
|
247
|
+
_cb(res instanceof Kareem.overwriteResult ? res : null);
|
|
248
|
+
},
|
|
249
|
+
err => _cb(err)
|
|
250
|
+
);
|
|
246
251
|
}
|
|
247
252
|
|
|
248
253
|
if (maybePromiseLike instanceof Kareem.overwriteResult) {
|
|
@@ -286,7 +291,7 @@ Kareem.prototype.createWrapperSync = function(name, fn) {
|
|
|
286
291
|
|
|
287
292
|
return result[0];
|
|
288
293
|
};
|
|
289
|
-
}
|
|
294
|
+
};
|
|
290
295
|
|
|
291
296
|
function _handleWrapError(instance, error, name, context, args, options, callback) {
|
|
292
297
|
if (options.useErrorHandlers) {
|
|
@@ -365,7 +370,7 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
|
|
|
365
370
|
}
|
|
366
371
|
arguments[0]
|
|
367
372
|
? lastArg(arguments[0])
|
|
368
|
-
: lastArg.apply(context, arguments)
|
|
373
|
+
: lastArg.apply(context, arguments);
|
|
369
374
|
});
|
|
370
375
|
}
|
|
371
376
|
}
|
|
@@ -553,6 +558,6 @@ function decorateNextFn(fn) {
|
|
|
553
558
|
|
|
554
559
|
const nextTick = typeof process === 'object' && process !== null && process.nextTick || function nextTick(cb) {
|
|
555
560
|
setTimeout(cb, 0);
|
|
556
|
-
}
|
|
561
|
+
};
|
|
557
562
|
|
|
558
563
|
module.exports = Kareem;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kareem",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Next-generation take on pre/post function hooks",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"lint": "eslint .",
|
|
7
8
|
"test": "mocha ./test/*",
|
|
8
9
|
"test-travis": "nyc mocha ./test/*"
|
|
9
10
|
},
|
|
@@ -12,8 +13,10 @@
|
|
|
12
13
|
"url": "git://github.com/vkarpov15/kareem.git"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
16
|
+
"@masteringjs/eslint-config": "0.0.1",
|
|
15
17
|
"acquit": "1.x",
|
|
16
18
|
"acquit-ignore": "0.1.x",
|
|
19
|
+
"eslint": "8.15.0",
|
|
17
20
|
"mocha": "9.2.0",
|
|
18
21
|
"nyc": "15.1.0"
|
|
19
22
|
},
|
package/test/examples.test.js
CHANGED
package/test/misc.test.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const Kareem = require('../');
|
|
5
|
+
const { describe, it } = require('mocha');
|
|
5
6
|
|
|
6
7
|
describe('hasHooks', function() {
|
|
7
8
|
it('returns false for toString (Automattic/mongoose#6538)', function() {
|
|
@@ -14,7 +15,6 @@ describe('merge', function() {
|
|
|
14
15
|
it('handles async pres if source doesnt have them', function() {
|
|
15
16
|
const k1 = new Kareem();
|
|
16
17
|
k1.pre('cook', true, function(next, done) {
|
|
17
|
-
execed.first = true;
|
|
18
18
|
setTimeout(
|
|
19
19
|
function() {
|
|
20
20
|
done('error!');
|
package/test/post.test.js
CHANGED
package/test/pre.test.js
CHANGED
package/test/wrap.test.js
CHANGED
package/gulpfile.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var gulp = require('gulp');
|
|
2
|
-
var mocha = require('gulp-mocha');
|
|
3
|
-
var config = require('./package.json');
|
|
4
|
-
var jscs = require('gulp-jscs');
|
|
5
|
-
|
|
6
|
-
gulp.task('mocha', function() {
|
|
7
|
-
return gulp.src('./test/*').
|
|
8
|
-
pipe(mocha({ reporter: 'dot' }));
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
gulp.task('jscs', function() {
|
|
12
|
-
return gulp.src('./index.js').
|
|
13
|
-
pipe(jscs(config.jscsConfig));
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
gulp.task('watch', function() {
|
|
17
|
-
gulp.watch('./index.js', ['jscs', 'mocha']);
|
|
18
|
-
});
|