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: Adds support for Yarn 2 #757

Closed
wants to merge 2 commits into from
Closed

Conversation

randallb
Copy link

Closes #517

@randallb
Copy link
Author

randallb commented Jul 19, 2022

I think this should probably have tests but I couldn't see anywhere to add them easily. Any thoughts? It also could just... not be tested... but it probably should be. :)

I'll try to build on replit at a minimum... will do sometime this week probably.

@joaomoreno pinging you since you own #517... do you have test opinions?

@randallb randallb marked this pull request as ready for review July 19, 2022 03:09
@randallb randallb marked this pull request as draft July 26, 2022 16:46
@joaomoreno
Copy link
Member

@joaomoreno pinging you since you own #517... do you have test opinions?

Not specific ones... just that it should probably be tested. ;)

(err, stdout) => (err ? e(err) : c(stdout))
)
);
const yarnCommand = versionString[0] !== 1 ? "yarn info --recursive --dependents --json" : 'yarn list --prod --json'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const yarnCommand = versionString[0] !== 1 ? "yarn info --recursive --dependents --json" : 'yarn list --prod --json'
const yarnCommand = versionString[0] !== "1" ? "yarn info --recursive --dependents --json" : 'yarn list --prod --json'

The versionString[0] !== 1 part causes a compilation error:

src/npm.ts:165:22 - error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap.

const raw = await new Promise<string>((c, e) =>
cp.exec(
'yarn list --prod --json',
yarnCommand,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 176 (where it says Could not parse result of […]) should be updated with yarnCommand as well; otherwise the error message is going to be misleading.

const raw = await new Promise<string>((c, e) =>
cp.exec(
'yarn list --prod --json',
yarnCommand,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that yarn info --recursive --dependents --json is a compatible drop-in replacement for yarn list --prod --json, anyway?

On Yarn v3.3.1, the former prints a list of JSON objects, for example:

{"value":"yallist@npm:4.0.0","children":{"Version":"4.0.0","Dependents":["lru-cache@npm:6.0.0","minipass@npm:3.3.6","minipass@npm:4.0.0","minizlib@npm:2.1.2","tar@npm:6.1.13"]}}

At least on Yarn 3.3.1, none of those lines seem to contain anything like "type":"tree". However, the code that follows seems to rely on just that. Consequently, vsce package now errors out for me in line 176, saying:

Could not parse result of `yarn list --json`

@randallb randallb closed this May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support yarn v2
3 participants