ovm
Version:
OVM is a CLI application for managing Obsidian vaults.
48 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.action = void 0;
const core_1 = require("@oclif/core");
const factory_1 = require("../../providers/factory");
const config_1 = require("../../services/config");
const command_1 = require("../../utils/command");
class Init extends factory_1.FactoryCommand {
static aliases = ['ci', 'config init'];
static description = `Configure an ovm.json config file in user's home dir`;
static examples = ['<%= config.bin %> <%= command.id %>'];
static flags = {
...this.commonFlags,
};
async run() {
try {
const { args, flags } = await this.parse(Init);
await (0, exports.action)(args, (0, command_1.flagsInterceptor)(flags));
}
catch (error) {
this.handleError(error);
}
finally {
(0, core_1.flush)();
}
}
}
exports.default = Init;
const action = async (args, flags, callback) => {
const { config: configPath } = flags;
const { data: config, error } = await (0, config_1.safeLoadConfig)(configPath);
if (error && error.message === 'Config file not found') {
const defaultConfig = await (0, config_1.createDefaultConfig)(configPath);
if (callback) {
callback(null);
}
return defaultConfig;
}
else if (error) {
if (callback) {
callback(error);
}
}
callback?.(null);
return config;
};
exports.action = action;
//# sourceMappingURL=init.js.map