fix(LocalAuth): only throw user-supplied userDataDir error if path is different

fix #1261
This commit is contained in:
Pedro Lopez
2022-03-01 22:25:22 -04:00
parent cc78e9863d
commit 1b75d0d243

View File

@@ -25,14 +25,13 @@ class LocalAuth extends BaseAuthStrategy {
async beforeBrowserInitialized() {
const puppeteerOpts = this.client.options.puppeteer;
if(puppeteerOpts.userDataDir) {
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
}
const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session';
const dirPath = path.join(this.dataPath, sessionDirName);
if(puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) {
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
}
fs.mkdirSync(dirPath, { recursive: true });
this.client.options.puppeteer = {