backend-manager 2.4.18 → 2.4.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "2.4.18",
3
+ "version": "2.4.19",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -66,4 +66,4 @@
66
66
  "src/",
67
67
  "templates/"
68
68
  ]
69
- }
69
+ }
@@ -27,8 +27,8 @@ Module.prototype.main = function () {
27
27
  return resolve({data: payload.data.payload.document});
28
28
  })
29
29
  .catch((e) => {
30
- return reject(assistant.errorManager(e, {code: 500, sentry: false, send: false, log: false}).error)
31
- });
30
+ return reject(assistant.errorManager(e, {code: 500, sentry: false, send: false, log: false}).error)
31
+ });
32
32
 
33
33
  }
34
34
 
@@ -538,11 +538,20 @@ Manager.prototype.storage = function (options) {
538
538
  options.name = options.name || 'main';
539
539
 
540
540
  if (!self._internal.storage[options.name]) {
541
+ options.temporary = typeof options.temporary === 'undefined' ? false : options.temporary;
542
+
541
543
  const low = require('lowdb');
542
544
  const FileSync = require('lowdb/adapters/FileSync');
543
- const dbPath = `./.data/${options.name}.json`;
545
+ const dbPath = options.temporary
546
+ ? `${require('os').tmpdir()}/${options.name}.json`
547
+ : `./.data/${options.name}.json`;
544
548
  const adapter = new FileSync(dbPath);
545
549
 
550
+ if (options.temporary && self.assistant.meta.environment === 'development') {
551
+ console.log('Removed temporary file @', dbPath);
552
+ jetpack.remove(dbPath);
553
+ }
554
+
546
555
  options.clearInvalid = typeof options.clearInvalid === 'undefined'
547
556
  ? true
548
557
  : options.clearInvalid;