I want to run a task in the root directory that uses a relative file reference in one of my packages. This is producing a not found error as the file is relative to the package, not to the root.
I have a db
package that is using kysely
and kysely-codegen
to generate a schema file. I am using the following shell script placed in packages/db/bin/generate_schema.sh
to do this
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
ROOT=$(realpath "$SCRIPT_DIR/..")
cat ${ROOT}/sql/create_db.sql | sqlite3 local.db;
DATABASE_URL=local.db bunx kysely-codegen --out-file ${ROOT}/src/schema/db.d.ts;
rm local.db;
In my package.json
I have the following scripts
"scripts": {
"dev": "tsc --watch",
"db:generate": "sh ./bin/generate_protos.sh"
},
And in my turbo.json
I have added
"tasks": {
...,
"db:generate": {}
}
bun run db:generate
works when I am in packages/db
, but running turbo run db:generate
produces the error sh: ./bin/generate_protos.sh: No such file or directory
. This fails whether I am in the root directory or in packages/db
Is there a way I can support this behaviour? I am fairly new to turborepo so maybe there is something I am missing?