spice-js 2.5.7 → 2.5.8
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/build/storage/Storage.js +3 -3
- package/package.json +1 -1
- package/src/storage/Storage.js +25 -23
package/build/storage/Storage.js
CHANGED
|
@@ -11,11 +11,11 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
11
11
|
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
|
|
14
|
-
var views = require(
|
|
14
|
+
var views = require("koa-views");
|
|
15
15
|
|
|
16
16
|
var path = require("path");
|
|
17
17
|
|
|
18
|
-
var juice = require(
|
|
18
|
+
var juice = require("juice");
|
|
19
19
|
|
|
20
20
|
class Storage {
|
|
21
21
|
constructor(args) {
|
|
@@ -47,7 +47,7 @@ class Storage {
|
|
|
47
47
|
var driver = new _this.Driver(_this.driver_options);
|
|
48
48
|
return yield driver.save({
|
|
49
49
|
files,
|
|
50
|
-
path
|
|
50
|
+
path: _this.driver_options.base_path ? _this.driver_options.base_path + "/" + path : path
|
|
51
51
|
});
|
|
52
52
|
})();
|
|
53
53
|
}
|
package/package.json
CHANGED
package/src/storage/Storage.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
var views = require(
|
|
1
|
+
var views = require("koa-views");
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const juice = require(
|
|
4
|
-
import _ from
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
}
|