Skip to content

Commit

Permalink
chore: remove pkg-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Aug 17, 2022
1 parent b80beec commit 39fe4cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 120 deletions.
120 changes: 3 additions & 117 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -75,7 +75,6 @@
"devtools-protocol": "0.0.1019158",
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.1",
"pkg-dir": "4.2.0",
"progress": "2.0.3",
"proxy-from-env": "1.1.0",
"rimraf": "3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/initializePuppeteer.ts
Expand Up @@ -14,18 +14,18 @@
* limitations under the License.
*/

import {sync} from 'pkg-dir';
import {Product} from './common/Product.js';
import {rootDirname} from './constants.js';
import {PuppeteerNode} from './node/Puppeteer.js';
import {PUPPETEER_REVISIONS} from './revisions.js';
import {getPackageDirectory} from './util/getPackageDirectory.js';

/**
* @internal
*/
export const initializePuppeteer = (packageName: string): PuppeteerNode => {
const isPuppeteerCore = packageName === 'puppeteer-core';
const puppeteerRootDirectory = sync(rootDirname);
const puppeteerRootDirectory = getPackageDirectory(rootDirname);
let preferredRevision = PUPPETEER_REVISIONS.chromium;
// puppeteer-core ignores environment variables
const productName = !isPuppeteerCore
Expand Down
15 changes: 15 additions & 0 deletions src/util/getPackageDirectory.ts
@@ -0,0 +1,15 @@
import {existsSync} from 'fs';
import {dirname, join, parse} from 'path';

export const getPackageDirectory = (from: string): string => {
let found = existsSync(join(from, 'package.json'));
const root = parse(from).root;
while (!found) {
if (from === root) {
throw new Error('Cannot find package directory');
}
from = dirname(from);
found = existsSync(join(from, 'package.json'));
}
return from;
};

0 comments on commit 39fe4cf

Please sign in to comment.