Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(npm6): resolve core relative to @ptw #99

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/playwrightTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ export class PlaywrightTest {

async getPlaywrightInfo(workspaceFolder: string, configFilePath: string): Promise<{ version: number, cli: string } | null> {
try {
const output = await this._runNode([
const pwtInfo = await this._runNode([
'-e',
'try { const index = require.resolve("playwright-core"); const version = require("@playwright/test/package.json").version; console.log(JSON.stringify({ index, version})); } catch { console.log("undefined"); }',
'try { const pwtIndex = require.resolve("@playwright/test"); const version = require("@playwright/test/package.json").version; console.log(JSON.stringify({ pwtIndex, version})); } catch { console.log("undefined"); }',
], path.dirname(configFilePath));
const { pwtIndex, version } = JSON.parse(pwtInfo);

const { index, version } = JSON.parse(output);
let cli = path.resolve(index, '..', 'lib', 'cli', 'cli');
// Resolve playwright-core relative to @playwright/test.
const coreInfo = await this._runNode([
'-e',
'try { const coreIndex = require.resolve("playwright-core"); console.log(JSON.stringify({ coreIndex })); } catch { console.log("undefined"); }',
], path.dirname(pwtIndex));
const { coreIndex } = JSON.parse(coreInfo);
let cli = path.resolve(coreIndex, '..', 'lib', 'cli', 'cli');

// Dogfood for 'ttest'
if (cli.includes('packages/playwright-core') && configFilePath.includes('playwright-test'))
Expand Down