mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Put chrome profiles into a temporary directory (#439)
This patch: - puts chrome profiles into a temporary directory - starts using `fs.mkdtemp` to create temp profile directories
This commit is contained in:
parent
1f9b4fb4c8
commit
11e3343b3d
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const removeSync = require('rimraf').sync;
|
||||
const childProcess = require('child_process');
|
||||
@ -20,12 +21,11 @@ const Downloader = require('../utils/ChromiumDownloader');
|
||||
const Connection = require('./Connection');
|
||||
const Browser = require('./Browser');
|
||||
const readline = require('readline');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const helper = require('./helper');
|
||||
const ChromiumRevision = require('../package.json').puppeteer.chromium_revision;
|
||||
|
||||
const CHROME_PROFILE_PATH = path.resolve(__dirname, '..', '.dev_profile');
|
||||
let browserId = 0;
|
||||
const CHROME_PROFILE_PATH = path.join(os.tmpdir(), 'puppeteer_dev_profile-');
|
||||
|
||||
const DEFAULT_ARGS = [
|
||||
'--disable-background-networking',
|
||||
@ -50,13 +50,9 @@ class Launcher {
|
||||
* @param {!Object=} options
|
||||
* @return {!Promise<!Browser>}
|
||||
*/
|
||||
static async launch(options = {}) {
|
||||
const userDataDir = [
|
||||
CHROME_PROFILE_PATH,
|
||||
process.pid,
|
||||
++browserId,
|
||||
crypto.randomBytes(8 / 2).toString('hex') // add random salt 8 characters long.
|
||||
].join('-');
|
||||
static async launch(options) {
|
||||
options = options || {};
|
||||
const userDataDir = fs.mkdtempSync(CHROME_PROFILE_PATH);
|
||||
|
||||
const chromeArguments = DEFAULT_ARGS.concat([
|
||||
`--user-data-dir=${userDataDir}`,
|
||||
|
Loading…
Reference in New Issue
Block a user