-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(yarn): download browsers to package directories
This patch makes it so all our packages, like `playwright` and browser-specific flavors, download browsers to their directories rather then using directory of `playwright-core`. This way yarn@1 caches are not busted: they didn't expect that directory content might change after packages's explicit install step is failed, there's that was what we were doing. Fixes #1085
- Loading branch information
1 parent
4ab8801
commit 4049f9d
Showing
6 changed files
with
82 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { helper } from './helper'; | ||
import * as api from './api'; | ||
|
||
import { DeviceDescriptors } from './deviceDescriptors'; | ||
import { TimeoutError } from './errors'; | ||
import { Chromium } from './server/chromium'; | ||
import { Firefox } from './server/firefox'; | ||
import { WebKit } from './server/webkit'; | ||
|
||
const packageJson = require('../package.json'); | ||
|
||
for (const className in api) { | ||
if (typeof (api as any)[className] === 'function') | ||
helper.installApiHooks(className[0].toLowerCase() + className.substring(1), (api as any)[className]); | ||
} | ||
|
||
type API = { | ||
devices: typeof DeviceDescriptors, | ||
errors: { TimeoutError: typeof TimeoutError }, | ||
chromium?: Chromium, | ||
firefox?: Firefox, | ||
webkit?: WebKit, | ||
selectors: api.Selectors, | ||
}; | ||
|
||
export function exportAPI(options: {downloadPath: string, browsers: Array<('firefox'|'webkit'|'chromium')>}): API { | ||
const { | ||
downloadPath = __dirname, | ||
browsers = ['webkit', 'chromium', 'firefox'], | ||
} = options; | ||
|
||
const result: API = { | ||
devices: DeviceDescriptors, | ||
errors: { TimeoutError }, | ||
selectors: api.Selectors._instance(), | ||
}; | ||
|
||
if (browsers.includes('webkit')) | ||
result.webkit = new WebKit(downloadPath, packageJson.playwright.webkit_revision); | ||
if (browsers.includes('chromium')) | ||
result.chromium = new Chromium(downloadPath, packageJson.playwright.chromium_revision); | ||
if (browsers.includes('firefox')) | ||
result.firefox = new Firefox(downloadPath, packageJson.playwright.firefox_revision); | ||
return result; | ||
} | ||
|