Compare commits
No commits in common. "62856686f20c2a627f4bafa92be24ef7f2d49a0d" and "e1d4785240c3815a5b0e376e96e0fb0edfd0c064" have entirely different histories.
62856686f2
...
e1d4785240
|
@ -11,8 +11,7 @@ import arg from "arg";
|
|||
export default class Config {
|
||||
private module;
|
||||
private data;
|
||||
private configProperty;
|
||||
constructor(module: string, configProperty: string);
|
||||
constructor(module: string);
|
||||
inject(options: object): void;
|
||||
load(): void;
|
||||
openDir(dir: string): void;
|
||||
|
|
|
@ -20,12 +20,10 @@ const deep_to_flat_object_1 = __importDefault(require("deep-to-flat-object"));
|
|||
class Config {
|
||||
module;
|
||||
data = {};
|
||||
configProperty;
|
||||
constructor(module, configProperty) {
|
||||
constructor(module) {
|
||||
(0, bsert_1.default)(typeof module === "string");
|
||||
(0, bsert_1.default)(module.length > 0);
|
||||
this.module = module;
|
||||
this.configProperty = configProperty;
|
||||
}
|
||||
inject(options) {
|
||||
for (const key of Object.keys(options)) {
|
||||
|
@ -72,7 +70,7 @@ class Config {
|
|||
save(file, data) {
|
||||
(0, bsert_1.default)(typeof data === "object");
|
||||
(0, bsert_1.default)(!Array.isArray(data));
|
||||
const configDir = this.str(this.configProperty);
|
||||
const configDir = this.str("configdir");
|
||||
const fullPath = path_1.default.join(configDir, `${file}.json`);
|
||||
if (!fs_1.default.existsSync(configDir)) {
|
||||
fs_1.default.mkdirSync(configDir, { recursive: true });
|
||||
|
|
|
@ -20,14 +20,12 @@ import deepToFlatObject from "deep-to-flat-object";
|
|||
export default class Config {
|
||||
private module: string;
|
||||
private data = {};
|
||||
private configProperty;
|
||||
|
||||
constructor(module: string, configProperty: string) {
|
||||
constructor(module: string) {
|
||||
assert(typeof module === "string");
|
||||
assert(module.length > 0);
|
||||
|
||||
this.module = module;
|
||||
this.configProperty = configProperty;
|
||||
}
|
||||
|
||||
public inject(options: object) {
|
||||
|
@ -85,7 +83,7 @@ export default class Config {
|
|||
assert(typeof data === "object");
|
||||
assert(!Array.isArray(data));
|
||||
|
||||
const configDir = this.str(this.configProperty);
|
||||
const configDir = this.str("configdir");
|
||||
const fullPath = Path.join(configDir, `${file}.json`);
|
||||
|
||||
if (!fs.existsSync(configDir)) {
|
||||
|
|
Loading…
Reference in New Issue