-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: use posix path for ts-node loader #22550
Conversation
* fix: distribute files to machines for external contributors. * fix path * fix * fix glob * fix * fix glob pattern spec->cy. * fix * echo things. * test * use cd. * fix component tests. * test * test * fix * refactor * test distribut-step fix error fix fix test TEST * Revert "test distribut-step" This reverts commit 15c3606. * Revert "refactor" This reverts commit 21a8ad9. * reduce flake by increasing viewport height Co-authored-by: Ryan Manuel <[email protected]> Co-authored-by: Lachlan Miller <[email protected]>
Co-authored-by: Lachlan Miller <[email protected]>
Thanks for taking the time to open a PR!
|
8cfd2ee
to
c246e37
Compare
@@ -103,7 +103,7 @@ export async function processConfigViaLegacyPlugins (projectRoot: string, legacy | |||
// this matches the 9.x behavior, which is what we want for | |||
// processing legacy pluginsFile (we never supported `"type": "module") in 9.x. | |||
if (hasTypeScriptInstalled(projectRoot)) { | |||
const tsNodeLoader = `--require ${tsNode}` | |||
const tsNodeLoader = `--require "${tsNode}"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before: --require C:\project with spaces\node_modules\ts-node\dist\ts-node.js
. Broken
Now: `--require "C:/project with spaces/node_modules/ts-node/dist/ts-node.js"
Needs posix and quotes. Would be great if someone can actually test on their machine (I did, and I added two tests with projects containing spaces, but good to clarify).
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
|
||
const debug = debugLib('cypress:data-context:MigrationActions') | ||
|
||
const tsNode = require.resolve('@packages/server/lib/plugins/child/register_ts_node') | ||
const tsNode = toPosix(require.resolve('@packages/server/lib/plugins/child/register_ts_node')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this helper necessary? Can we use path.joint out of the box?
const tsNode = toPosix(require.resolve('@packages/server/lib/plugins/child/register_ts_node')) | |
const tsNode = require.resolve(path.join('@packages', 'server', 'lib','plugins','child', 'register_ts_node')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilyrohrbough I believe the intent here is to properly escape the actual resolved path that's returned from require.resolve
, which path.join
wouldn't help with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the helper is the fix. We need to posix-ify the path, even on windows.
@@ -17,7 +17,7 @@ const debug = debugLib(`cypress:lifecycle:ProjectConfigIpc`) | |||
const CHILD_PROCESS_FILE_PATH = require.resolve('@packages/server/lib/plugins/child/require_async_child') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets fix CHILD_PROCESS_FILE_PATH one as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is actually a problem? Eg - I added regression tests, none of them fail. Kind of hesitant to add this helper unless it's actually necessary.
We use it like this:
const proc = fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions)
I think fork
must be smart enough to escape the path on its own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I see https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
- Windows: /AppData/Local/Cypress/Cache
Since Cypress is always in a directory w/o a space, this has never been a problem. If it's never been a problem, I am kind of hesitant to add this change right now before shipping (without another round of manual testing and a way to reproduce the error it's meant to be fixing.
User facing changelog
Correctly escape
ts-node
require when running on windows.Additional details
Fixes a bug where TypeScript users with spaces in their path could not launch Cypress. Introduced in abd986a#diff-b0bd90502ad464c0d541a0e47822d15fec9ba5434dc4225d2993305e1ec7d30aR19.
require.resolve
returns a path which we pass toNODE_OPTIONS
in the form of--require <path>
which errors if there is white space in the path. The fix is to change the path to use posix separators.Steps to test
yarn dev
wasn't working - now it isHow has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?