@makano/rew 1.2.2 → 1.2.21
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/pkgs/conf.js +8 -1
- package/lib/rew/pkgs/rune.js +2 -2
- package/package.json +1 -1
package/lib/rew/pkgs/conf.js
CHANGED
@@ -49,9 +49,16 @@ module.exports = (context) => ({
|
|
49
49
|
const fileRoot = path.join(rootPath, name);
|
50
50
|
const exists = fs.existsSync(fileRoot);
|
51
51
|
return {
|
52
|
-
|
52
|
+
write(value, ifExists) {
|
53
53
|
if (!fs.existsSync(path.dirname(fileRoot))) fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
|
54
|
+
if(ifExists && fs.existsSync(fileRoot)) return this;
|
54
55
|
fs.writeFileSync(fileRoot, value || defaultValue);
|
56
|
+
return this;
|
57
|
+
},
|
58
|
+
read(s){
|
59
|
+
let file = fs.readFileSync(fileRoot);
|
60
|
+
return typeof s == "string" ? file.toString() :
|
61
|
+
typeof s == "object" ? file.toJSON() : file;
|
55
62
|
},
|
56
63
|
fileRoot,
|
57
64
|
exists,
|
package/lib/rew/pkgs/rune.js
CHANGED