bun icon indicating copy to clipboard operation
bun copied to clipboard

Do not elide lines with `bun run` with workspaces

Open spiffytech opened this issue 1 year ago • 12 comments
trafficstars

What is the problem this feature would solve?

My DB migration library prints out what's wrong with my SQL, but running bun run migrate from my project top-level omits the most important lines from the error: the SQL error message.

$ bun run migrate
$ bun run --filter server --env-file .env migrate
server migrate $ bunx pg-migrations apply --directory migrations && bunx @databases/pg-schema-cli --directory __generated__
│ [8 lines elided]
│     at handleError (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:394:29)
│     at executeQueryInternal (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:369:9)
│     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
│     at async PgDriver._executeQuery (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:199:29)
│     at async PgDriver.executeAndReturnLast (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:226:16)
│     at async Transaction.query (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/shared/lib/BaseTransaction.js:59:24)
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:19:25
│     at async Object.applyMigration (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:137:21)
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/migrations-base/lib/methods/applyOperations.js:43:29
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:54:20
└─ Exited with code 1
error: script "migrate" exited with code 1

If I cd into packages/server and run the same command manually I get the full error:

$ bun run --env-file ../../.env migrate
$ bunx pg-migrations apply --directory migrations && bunx @databases/pg-schema-cli --directory __generated__
Applying 0003-lifts-order.sql
error: column lifts.id does not exist

  16 |   ) as subquery
  17 | where
> 18 |   lifts.id = subquery.id
     |   ^

    at handleError (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:394:29)
    at executeQueryInternal (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:369:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PgDriver._executeQuery (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:199:29)
    at async PgDriver.executeAndReturnLast (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:226:16)
    at async Transaction.query (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/shared/lib/BaseTransaction.js:59:24)
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:19:25
    at async Object.applyMigration (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:137:21)
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/migrations-base/lib/methods/applyOperations.js:43:29
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:54:20
error: script "migrate" exited with code 1

What is the feature you are proposing to solve the problem?

A way for bun run to print the entire, unabridged output from workspace scripts. Maybe by default, maybe with a flag.

What alternatives have you considered?

Just not using top-level package.json scripts if they're not gonna show me complete output, but then I have to specify the .env file for every command

spiffytech avatar Jul 08 '24 14:07 spiffytech