-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support Yarn v3 (berry) #48
base: master
Are you sure you want to change the base?
Changes from 2 commits
dfb95f2
ccfccd0
0e99737
1c8d856
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ const globby = require("globby") | |
const checksum = require("checksum") | ||
const merge = require("lodash/merge") | ||
const debounce = require("lodash/debounce") | ||
const { spawn } = require("yarn-or-npm") | ||
const { spawn, hasYarn } = require("yarn-or-npm") | ||
const tar = require("tar") | ||
|
||
async function installRelativeDeps() { | ||
|
@@ -154,10 +154,22 @@ function packAndInstallLibrary(name, dir, targetDir) { | |
fs.mkdirSync(libDestDir, { recursive: true }) | ||
|
||
const tmpName = name.replace(/[\s\/]/g, "-").replace(/@/g, "") | ||
|
||
|
||
|
||
// npm replaces @... with at- where yarn just removes it, so we test for both files here | ||
const regex = new RegExp(`^(at-)?${tmpName}(.*).tgz$`) | ||
|
||
const packagedName = fs.readdirSync(dir).find(file => regex.test(file)) | ||
let packagedName = fs.readdirSync(dir).find(file => regex.test(file)) | ||
|
||
if(hasYarn) { | ||
let yarnVersion = spawn.sync(['-v'], { cwd: dir, encoding: "utf8" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
if(yarnVersion.stdout.replace('\n','').split('.')[0] >= 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
packagedName = "package.tgz" | ||
} | ||
} | ||
|
||
fullPackageName = path.join(dir, packagedName) | ||
|
||
console.log(`[relative-deps] Extracting "${fullPackageName}" to ${libDestDir}`) | ||
|
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.
According to the docs,
hasYarn
is a function.Have you tested your code on yarn 1 or 2 with these changes?