browsertime 17.0.0-beta.1 → 17.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ const CHROME_AMD_EDGE_INTERNAL_PHONE_HOME = [
11
11
  '"MAP cache.pack.google.com 127.0.0.1"',
12
12
  '"MAP clients1.google.com 127.0.0.1"',
13
13
  '"MAP update.googleapis.com 127.0.0.1"',
14
+ '"MAP content-autofill.googleapis.com 127.0.0.1"',
14
15
  '"MAP redirector.gvt1.com 127.0.0.1"',
15
16
  '"MAP laptop-updates.brave.com 127.0.0.1"',
16
17
  '"MAP offlinepages-pa.googleapis.com 127.0.0.1"',
@@ -163,7 +163,8 @@ export async function configureBuilder(builder, baseDir, options) {
163
163
  ffOptions.setPreference(name, false);
164
164
  } else if (value === 'true') {
165
165
  ffOptions.setPreference(name, true);
166
- } else if (Number.isNaN(value)) {
166
+ // eslint-disable-next-line unicorn/prefer-number-properties
167
+ } else if (isNaN(value)) {
167
168
  ffOptions.setPreference(name, value);
168
169
  } else {
169
170
  ffOptions.setPreference(name, Number(value));
@@ -1,19 +1,20 @@
1
- import { resolve } from 'node:path';
1
+ import { resolve, join, sep } from 'node:path';
2
+ import os from 'node:os';
2
3
  import { createRequire } from 'node:module';
3
4
  import dayjs from 'dayjs';
4
5
  import intel from 'intel';
5
6
  import { toArray } from '../support/util.js';
6
- import {
7
- removeFile,
8
- copyFile,
9
- removeFileSync,
10
- copyFileSync
11
- } from './fileUtil.js';
7
+ import { copyFile, copyFileSync } from './fileUtil.js';
8
+ import { realpathSync, mkdtempSync, rmdirSync } from 'node:fs';
12
9
  const require = createRequire(import.meta.url);
13
10
  const log = intel.getLogger('browsertime');
14
11
 
15
12
  const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
16
13
 
14
+ function getTmp() {
15
+ return mkdtempSync(realpathSync(os.tmpdir()) + sep);
16
+ }
17
+
17
18
  export function loadPrePostScriptsSync(scripts) {
18
19
  return toArray(scripts).map(script => {
19
20
  // if the script is an AsyncFunction, return it.
@@ -22,10 +23,11 @@ export function loadPrePostScriptsSync(scripts) {
22
23
  }
23
24
  try {
24
25
  if (script.endsWith('.js')) {
25
- const name = script + '.cjs';
26
+ const dir = getTmp();
27
+ const name = join(dir, 'tmp.cjs');
26
28
  copyFileSync(script, name);
27
29
  const data = require(resolve(name));
28
- removeFileSync(name);
30
+ rmdirSync(dir, { recursive: true });
29
31
  return data;
30
32
  } else {
31
33
  return require(resolve(script));
@@ -44,10 +46,11 @@ export function loadScriptSync(script) {
44
46
  }
45
47
  try {
46
48
  if (script.endsWith('.js')) {
47
- const name = script + '.cjs';
49
+ const dir = getTmp();
50
+ const name = join(dir, 'tmp.cjs');
48
51
  copyFileSync(script, name);
49
52
  const data = require(resolve(name));
50
- removeFileSync(name);
53
+ rmdirSync(dir, { recursive: true });
51
54
  return data;
52
55
  } else {
53
56
  return require(resolve(script));
@@ -66,10 +69,11 @@ export async function loadScript(script, throwError) {
66
69
  }
67
70
  try {
68
71
  if (script.endsWith('.js')) {
69
- const name = script + '.cjs';
72
+ const dir = getTmp();
73
+ const name = join(dir, 'tmp.cjs');
70
74
  await copyFile(script, name);
71
75
  const data = require(resolve(name));
72
- await removeFile(name);
76
+ rmdirSync(dir, { recursive: true });
73
77
  return data;
74
78
  } else {
75
79
  return require(resolve(script));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "17.0.0-beta.1",
3
+ "version": "17.0.0-beta.3",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "type": "module",
6
6
  "dependencies": {