Open RobinCsl opened 5 years ago
If it helps, you can actually replicate exactly what yarn workspaces does by shelling out to yarn
itself
const cp = require('child_process');
function getWorkspaces(fromDir) {
const cwd = fromDir || process.cwd();
const workspacesStr = cp.execSync('yarn -s workspaces info', { cwd }).toString();
return JSON.parse(workspacesStr)
}
Works from any directory, will always match whatever new rules are added by yarn and doesn't need any extra deps. You'll get something with this shape
{
"pkg-bar": {
"location": "packages/bar",
"workspaceDependencies": ["pkg-baz"],
"mismatchedWorkspaceDependencies": ["pkg-foo"]
},
"pkg-baz": {
"location": "packages/baz",
"workspaceDependencies": [],
"mismatchedWorkspaceDependencies": []
},
"pkg-foo": {
"location": "packages/foo",
"workspaceDependencies": [],
"mismatchedWorkspaceDependencies": []
}
}
Thanks @lukebatchelor, I will try and have a look if that would my situation simpler.
Hello @dariocravero,
Thank you very much for this library!
I found something interesting:
when installing
get-yarn-workspaces
, I get the followingindex.js
file:You can see that the penultimate line
does not filter out files, unlike the version of this file on this repository:
The
package.json
files downloaded in my node_modules has the correct version, namely 1.0.2.This caused some nasty bug which was very difficult to pinpoint: a README.md file in the workspace folder seems so innocent! 😄
Could you please inquire? It could be worth bumping the patch version and then publish it to npm.
If I can be of any assistance, please let me know. Thank you very much.