@wocker/core 1.0.15 → 1.0.17-dev.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.
|
@@ -12,7 +12,8 @@ export declare class FileSystem {
|
|
|
12
12
|
mkdir(path: string, options?: FS.MakeDirectoryOptions): void;
|
|
13
13
|
readdir(...parts: string[]): Promise<unknown>;
|
|
14
14
|
readdirFiles(path?: string, options?: ReaddirOptions): Promise<string[]>;
|
|
15
|
-
readJSON(...paths: string[]):
|
|
15
|
+
readJSON(...paths: string[]): any;
|
|
16
|
+
writeFile(path: string, data: string | Buffer): Promise<void>;
|
|
16
17
|
writeJSON(path: string, data: any, options?: WriteFileOptions): Promise<void>;
|
|
17
18
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
18
19
|
}
|
package/lib/makes/FileSystem.js
CHANGED
|
@@ -94,18 +94,20 @@ class FileSystem {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
readJSON(...paths) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
const filePath = this.path(...paths);
|
|
98
|
+
const res = fs_2.default.readFileSync(filePath);
|
|
99
|
+
return JSON.parse(res.toString());
|
|
100
|
+
}
|
|
101
|
+
writeFile(path, data) {
|
|
102
|
+
const fullPath = this.path(path);
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
fs_2.default.writeFile(fullPath, data, (err) => {
|
|
105
|
+
if (err) {
|
|
106
|
+
reject(err);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
resolve(undefined);
|
|
107
110
|
});
|
|
108
|
-
return JSON.parse(res.toString());
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
113
|
writeJSON(path, data, options) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppConfig } from "../makes";
|
|
2
2
|
declare abstract class AppConfigService {
|
|
3
|
-
protected config?:
|
|
4
|
-
abstract getPWD(): string;
|
|
3
|
+
protected config?: AppConfig;
|
|
5
4
|
abstract setPWD(pwd: string): void;
|
|
5
|
+
abstract pwd(...parts: string[]): string;
|
|
6
6
|
abstract dataPath(...args: string[]): string;
|
|
7
7
|
abstract pluginsPath(...args: string[]): string;
|
|
8
|
-
getConfig():
|
|
9
|
-
protected abstract loadConfig():
|
|
8
|
+
getConfig(): AppConfig;
|
|
9
|
+
protected abstract loadConfig(): AppConfig;
|
|
10
10
|
}
|
|
11
11
|
export { AppConfigService };
|
|
@@ -5,26 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
9
|
exports.AppConfigService = void 0;
|
|
19
10
|
const decorators_1 = require("../decorators");
|
|
20
11
|
let AppConfigService = class AppConfigService {
|
|
21
12
|
getConfig() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return this.config;
|
|
27
|
-
});
|
|
13
|
+
if (!this.config) {
|
|
14
|
+
this.config = this.loadConfig();
|
|
15
|
+
}
|
|
16
|
+
return this.config;
|
|
28
17
|
}
|
|
29
18
|
};
|
|
30
19
|
exports.AppConfigService = AppConfigService;
|