diff --git a/cli.json b/cli.json index 039cf25..a9fdf29 100644 --- a/cli.json +++ b/cli.json @@ -5,13 +5,13 @@ "commands": [ { "name": "edgeworkers", - "version": "1.7.2", + "version": "1.7.3", "aliases": ["ew", "edgeworkers"], "description": "Manage Akamai EdgeWorkers code bundles." }, { "name": "edgekv", - "version": "1.7.2", + "version": "1.7.3", "aliases": ["ekv", "edgekv"], "description": "Manage Akamai EdgeKV database." } diff --git a/package-lock.json b/package-lock.json index e314906..b8a781e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "akamai-edgeworkers-cli", - "version": "1.7.2", + "version": "1.7.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "akamai-edgeworkers-cli", - "version": "1.7.2", + "version": "1.7.3", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 3b63b53..eaf656e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "akamai-edgeworkers-cli", - "version": "1.7.2", + "version": "1.7.3", "description": "A tool that makes it easier to manage Akamai EdgeWorkers code bundles and EdgeKV databases. Call the EdgeWorkers and EdgeKV API from the command line.", "repository": "https://github.com/akamai/cli-edgeworkers", "scripts": { diff --git a/src/utils/config-utils.ts b/src/utils/config-utils.ts index a2f8310..143b983 100644 --- a/src/utils/config-utils.ts +++ b/src/utils/config-utils.ts @@ -21,6 +21,7 @@ export const Operations = { export class Config { path: string; section: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any config: any; constructor(path: string, section: string) { @@ -28,10 +29,16 @@ export class Config { this.section = section; // create a config file if it doesn't exist - if (!fs.existsSync(this.path)) { - fs.writeFileSync(this.path, ''); + try { + if (!fs.existsSync(this.path)) { + fs.writeFileSync(this.path, ''); + } + this.config = ini.parse(fs.readFileSync(this.path, 'utf8')); + } catch (e) { + // When fail to write or read the config file, treat it as an empty config file + console.error(`File path not found: ${this.path}`); + this.config = {}; } - this.config = ini.parse(fs.readFileSync(this.path, 'utf8')); // initialize the section if not exist if (!(this.section in this.config)) { @@ -39,6 +46,7 @@ export class Config { } } + // eslint-disable-next-line @typescript-eslint/no-explicit-any save(context: any=null) { try { if (context) {