diff --git a/SECURITY.md b/SECURITY.md index 7f7a3e3..5494f10 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,16 +1,3 @@ # Security Policy -## Supported Versions - -This project is updated on a monthly basis unless there are security issues that need addressed that day. - -| Version | Supported | -| ------- | ------------------ | -| >3.0.0 | :white_check_mark: | -| 2.0.0 | not supported | -| 1.0.0 | not supported | - - -## Reporting a Vulnerability - -To report a vulnerability please create an issue and assign the owner 'Jared Wray' to it as it will notify him and he is actively maintaining this project. +We attempt to keep this project up to date with the latest modules on a regular basis. Please make sure to upgrade to the latest to avoid major issues. To report a vulnerability please create an issue and assign the owner 'Jared Wray' to it as it will notify him and he is actively maintaining this project. diff --git a/src/writr.ts b/src/writr.ts index 06eb7c7..40d2e96 100644 --- a/src/writr.ts +++ b/src/writr.ts @@ -412,14 +412,22 @@ export class Writr extends Hookified { * @returns {Promise} */ public async loadFromFile(filePath: string): Promise { - const {readFile} = fs.promises; - const data = { - content: '', - }; - data.content = await readFile(filePath, 'utf8'); - - await this.hook(WritrHooks.loadFromFile, data); - this._content = data.content; + try { + const {readFile} = fs.promises; + const data = { + content: '', + }; + data.content = await readFile(filePath, 'utf8'); + + await this.hook(WritrHooks.loadFromFile, data); + this._content = data.content; + /* c8 ignore next 6 */ + } catch (error) { + this.emit('error', error); + if (this._options.throwErrors) { + throw error; + } + } } /** @@ -428,14 +436,22 @@ export class Writr extends Hookified { * @returns {void} */ public loadFromFileSync(filePath: string): void { - const data = { - content: '', - }; - data.content = fs.readFileSync(filePath, 'utf8'); - - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.hook(WritrHooks.loadFromFile, data); - this._content = data.content; + try { + const data = { + content: '', + }; + data.content = fs.readFileSync(filePath, 'utf8'); + + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this.hook(WritrHooks.loadFromFile, data); + this._content = data.content; + /* c8 ignore next 6 */ + } catch (error) { + this.emit('error', error); + if (this._options.throwErrors) { + throw error; + } + } } /**