Skip to content

Commit

Permalink
feat: release headless: true
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Jul 21, 2023
1 parent 203ea98 commit dc90954
Show file tree
Hide file tree
Showing 4 changed files with 8,440 additions and 8,424 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ venom
browserPathExecutable: '', // browser executable path
folderNameToken: 'tokens', //folder name when saving tokens
mkdirFolderToken: '', //folder directory tokens, just inside the venom folder, example: { mkdirFolderToken: '/node_modules', } //will save the tokens folder in the node_modules directory
headless: true, // you should no longer use boolean false or true, now use false, true or 'new' learn more https://developer.chrome.com/articles/new-headless/
headless: 'new', // you should no longer use boolean false or true, now use false, true or 'new' learn more https://developer.chrome.com/articles/new-headless/
devtools: false, // Open devtools by default
debug: false, // Opens a debug session
logQR: true, // Logs QR automatically in terminal
Expand Down
22 changes: 19 additions & 3 deletions src/controllers/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,20 @@ export async function initBrowser(
if (!checkFolder) {
throw new Error(`Error executing client session info`);
}
if (options.headless !== 'new' && options.headless !== false) {
throw new Error('Now use only headless: "new" or false');

// Check for deprecated headless option
if (options.headless === true) {
console.warn(
'Warning: The usage of "headless: true" is deprecated. Please use "headless: \'new\'" or "headless: false" instead. https://developer.chrome.com/articles/new-headless/'
);
}

if (
options.headless !== 'new' &&
options.headless !== false &&
options.headless !== true
) {
throw new Error('Now use only headless: "new", "true" or false');
}

const chromePath = getChromeExecutablePath();
Expand Down Expand Up @@ -605,7 +617,11 @@ function removeStoredSingletonLock(
return new Promise((resolve, reject) => {
const platform = os.platform();
const { userDataDir } = puppeteerOptions;
const singletonLockPath = path.join(process.cwd(), userDataDir, 'SingletonLock');
const singletonLockPath = path.join(
process.cwd(),
userDataDir,
'SingletonLock'
);

if (platform === 'win32') {
// No need to remove the lock on Windows, so resolve with true directly.
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const venom = require('../dist');

venom.create({
session: 'sessionname', //name of session
headless: false
headless: true
}).then(()=> {
start(client);
});
Expand Down
Loading

1 comment on commit dc90954

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.