spice-js 2.5.5 → 2.5.9

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.
@@ -1,28 +1,30 @@
1
- var views = require('koa-views');
1
+ var views = require("koa-views");
2
2
  const path = require("path");
3
- const juice = require('juice');
4
- import _ from 'lodash';
5
-
3
+ const juice = require("juice");
4
+ import _ from "lodash";
6
5
 
7
6
  export default class Storage {
7
+ constructor(args = {}) {
8
+ this.driver_name = args.driver_name || spice.config.storage.default_driver;
9
+ this.driver_options = _.merge(
10
+ spice.config.storage.drivers[this.driver_name],
11
+ args.options
12
+ );
13
+ //console.log(this.driver_name, spice.config.storage.providers)
14
+ this.Driver = spice.config.storage.providers[this.driver_name];
15
+ }
8
16
 
9
- constructor(args = {}) {
10
- this.driver_name = args.driver_name || spice.config.storage.default_driver;
11
- this.driver_options = _.merge(spice.config.storage.drivers[this.driver_name], args.options);
12
- //console.log(this.driver_name, spice.config.storage.providers)
13
- this.Driver = spice.config.storage.providers[this.driver_name];
14
- }
15
-
16
-
17
- async save({files, path,
18
- options,
19
- }) {
20
- if (options) {
21
- this.driver_options = _.merge(this.driver_options, options);
22
- }
23
- //console.log(this.Driver);
24
- let driver = new this.Driver(this.driver_options);
25
-
26
- return await driver.save({files, path});
17
+ async save({ files, path, options }) {
18
+ if (options) {
19
+ this.driver_options = _.merge(this.driver_options, options);
27
20
  }
28
- }
21
+ //console.log(this.Driver);
22
+ let driver = new this.Driver(this.driver_options);
23
+ return await driver.save({
24
+ files,
25
+ path: this.driver_options.base_path
26
+ ? `${this.driver_options.base_path}/${path}`
27
+ : path,
28
+ });
29
+ }
30
+ }