-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 bun run --workspaces
#5207
Comments
pnpm has a I suggest doing something similar (if not the same) for bun |
Would love to see this for the sake of monorepo support |
+Without this, a monorepo is quite hard to manage when it comes to slim and performant docker images made from monorepo parts |
Seems like a nice QOL issue which could increase early adoption |
Bump, please add support for this, even if it's a simple cd in and cd out. |
Yes please. Much needed feature for monorepos. |
Yes Please , Great help to make everything works the same |
You can create your own in {
"scripts": {
"workspace": "bun ./scripts/workspace.ts"
}
}
File content// ./scripts/workspace.ts
import { file } from 'bun';
import { join } from 'node:path';
const [, , workspace, script] = process.argv;
const runScriptForWorkspace = (w: string) =>
new Promise<number>((resolve, reject) => {
console.info(`Running script "${script}" in workspace "${w}"`);
Bun.spawn({
cmd: ['bun', 'run', script],
cwd: `./${w}`,
stdio: ['inherit', 'inherit', 'inherit'],
onExit(info) {
if (info.exitCode !== 0) {
console.log('The script failed', info.exitCode);
reject(info.exitCode);
} else {
console.log('The script ran successfully');
resolve(info.exitCode);
}
},
});
});
if (workspace.includes(',')) {
const workspaces = workspace.split(',');
for (const w of workspaces) {
runScriptForWorkspace(w);
}
} else if (workspace !== 'all' && !workspace.startsWith('-'))
runScriptForWorkspace(workspace);
else {
const excluded = workspace.startsWith('-') && workspace.slice(1);
const packageJson = JSON.parse(
await file(join(import.meta.dir, '../package.json')).text(),
);
const workspaces = packageJson.workspaces as string[];
for (const w of workspaces) {
if (w === excluded) continue;
await runScriptForWorkspace(w);
}
} Then you can run workspaces with Here's an example of a project using workspaces with https://github.com/rehype-pretty/rehype-pretty-code/blob/4a41af0c8fb706e26bdd00aec54b9bc384fc318a/package.json#L28 |
What is the problem this feature would solve?
Run a package.json script in all workspaces (if it is defined)
What is the feature you are proposing to solve the problem?
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: