We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
get-yarn-workspaces
Hello @dariocravero,
Thank you very much for this library!
I found something interesting:
when installing get-yarn-workspaces, I get the following index.js file:
index.js
const findRoot = require('find-root'); const flatten = require('flatten'); const fs = require('fs'); const path = require('path'); const glob = require('glob'); // as per https://yarnpkg.com/blog/2018/02/15/nohoist/ - // "workspaces" can be an array or an object that contains "packages" function getPackages(packageJson) { if (!('workspaces' in packageJson)) { return null; } const {workspaces} = packageJson; if (Array.isArray(workspaces)) { return workspaces; } return workspaces.packages || null; } module.exports = function getWorkspaces(from) { const root = findRoot(from, dir => { const pkg = path.join(dir, 'package.json'); return fs.existsSync(pkg) && getPackages(require(pkg)) !== null; }); const packages = getPackages(require(path.join(root, 'package.json'))); return flatten(packages.map(name => glob.sync(path.join(root, name)))); };
You can see that the penultimate line
return flatten(packages.map(name => glob.sync(path.join(root, name))));
does not filter out files, unlike the version of this file on this repository:
return flatten(packages.map(name => glob.sync(path.join(root, `${name}/`))));
The package.json files downloaded in my node_modules has the correct version, namely 1.0.2.
package.json
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.
The text was updated successfully, but these errors were encountered:
If it helps, you can actually replicate exactly what yarn workspaces does by shelling out to yarn itself
yarn
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": [] } }
Sorry, something went wrong.
Thanks @lukebatchelor, I will try and have a look if that would my situation simpler.
No branches or pull requests
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.
The text was updated successfully, but these errors were encountered: