chore: cleanup, ci workflows and formatting (#127064)
* ci: setup workflows, dependabot, labeler and commit linting * docs: update README, community files and issue templates * chore: configure prettier, editorconfig and format codebase * chore: restore changes lost during rebase * docs: adjust url for new logo * fix: align badges * chore: resolve conflicts and re-add temp lint
This commit is contained in:
parent
c2d978fd0a
commit
807efd502d
1 changed files with 6790 additions and 3547 deletions
|
|
@ -6,7 +6,7 @@ const { WebCache, VersionResolveError } = require('./WebCache');
|
|||
/**
|
||||
* LocalWebCache - Fetches a WhatsApp Web version from a local file store
|
||||
* @param {object} options - options
|
||||
* @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
|
||||
* @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
|
||||
* @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version.
|
||||
*/
|
||||
class LocalWebCache extends WebCache {
|
||||
|
|
@ -19,12 +19,14 @@ class LocalWebCache extends WebCache {
|
|||
|
||||
async resolve(version) {
|
||||
const filePath = path.join(this.path, `${version}.html`);
|
||||
|
||||
|
||||
try {
|
||||
return fs.readFileSync(filePath, 'utf-8');
|
||||
}
|
||||
catch (err) {
|
||||
if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the cache`);
|
||||
} catch (err) {
|
||||
if (this.strict)
|
||||
throw new VersionResolveError(
|
||||
`Couldn't load version ${version} from the cache`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue