Skip to content

Support Yarn v3 (berry)#48

Open
jonstuebe wants to merge 4 commits intomweststrate:masterfrom
smartrent:master
Open

Support Yarn v3 (berry)#48
jonstuebe wants to merge 4 commits intomweststrate:masterfrom
smartrent:master

Conversation

@jonstuebe
Copy link
Copy Markdown

When using yarn berry the pack command always outputs package.tgz instead of using the package name in the filename. This patch fixes that issue.

Comment thread index.js
const packagedName = fs.readdirSync(dir).find(file => regex.test(file))
let packagedName = fs.readdirSync(dir).find(file => regex.test(file))

if(hasYarn) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

According to the docs, hasYarn is a function.

Have you tested your code on yarn 1 or 2 with these changes?

Comment thread index.js
let packagedName = fs.readdirSync(dir).find(file => regex.test(file))

if(hasYarn) {
let yarnVersion = spawn.sync(['-v'], { cwd: dir, encoding: "utf8" });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't there a longhand version of the same flag, which will clearly signal the intent of the command? I know that yarn@1 has --version in addition to -v.

Comment thread index.js
if(hasYarn) {
let yarnVersion = spawn.sync(['-v'], { cwd: dir, encoding: "utf8" });

if(yarnVersion.stdout.replace('\n','').split('.')[0] >= 3) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non strict comparison with type coercion is a strongly discouraged because it is very error prone. Can we do it in a more safe manner?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, I can use a semver parsing library if that works. I'll work on this over the next couple of days.

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.

3 participants