@tryghost/bookshelf-transaction-events 0.1.14 → 0.2.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.
@@ -3,21 +3,23 @@
3
3
  * https://github.com/tgriesser/knex/issues/1641
4
4
  */
5
5
  module.exports = function (bookshelf) {
6
- const orig1 = bookshelf.transaction;
6
+ const originalTransaction = bookshelf.transaction;
7
7
 
8
8
  bookshelf.transaction = function (cb) {
9
- return orig1.bind(bookshelf)(function (t) {
10
- const orig2 = t.commit;
11
- const orig3 = t.rollback;
9
+ return originalTransaction.bind(bookshelf)(function (t) {
10
+ const originalCommit = t.commit;
11
+ const originalRollback = t.rollback;
12
12
 
13
- t.commit = function () {
13
+ t.commit = async function () {
14
+ const originalReturn = await originalCommit.apply(t, arguments);
14
15
  t.emit('committed', true);
15
- return orig2.apply(t, arguments);
16
+ return originalReturn;
16
17
  };
17
18
 
18
- t.rollback = function () {
19
+ t.rollback = async function () {
20
+ const originalReturn = await originalRollback.apply(t, arguments);
19
21
  t.emit('committed', false);
20
- return orig3.apply(t, arguments);
22
+ return originalReturn;
21
23
  };
22
24
 
23
25
  return cb(t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/bookshelf-transaction-events",
3
- "version": "0.1.14",
3
+ "version": "0.2.0",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/bookshelf-transaction-events",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -19,9 +19,11 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
+ "knex": "2.3.0",
22
23
  "mocha": "10.0.0",
23
24
  "should": "13.2.3",
24
- "sinon": "14.0.0"
25
+ "sinon": "14.0.1",
26
+ "sqlite3": "5.1.2"
25
27
  },
26
- "gitHead": "6b46efd28457ee4b86cf4ae9da9bf87238099ddd"
28
+ "gitHead": "73748c86fd0a1416792974234dfe88e3f5a62f25"
27
29
  }