Skip to content
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

Do not overwrite cwd if knexfile and cwd is passed #6060

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petar-lazarov
Copy link

@petar-lazarov petar-lazarov commented Apr 19, 2024

When having both --cwd argument and --knexfile argument, the knexfile basepath overwrites the process cwd which is strange IMO.

If we pass --cwd it should have higher precedence than the basepath of the --knexfile for process cwd selection.

My use case for knex is strange. I'm trying to integrate it in firebase project and I want the configuration values for password and username to be loaded by firebase runtime configuration.

The file structure looks like this

.
├── src
│   ├── migrations
│   │   └── ...
│   ├── index.ts
│   ├── knexfile.ts
├── .runtimeconfig.json

I wanted the knexfile.ts and migrations to be under src directory but the .runtimeconfig.json should be in the parent directory and it contains the values for those variables.

When I execute from .:

knex --knexfile src/knexfile.ts --cwd . migrate:status

the working directory is initially . but after that it is overwritten by ./src/.

You cannot tell to firebase where to find its .runtimeconfig.json. It always search for it in the current working directory I think.

I found two pull requests that are related to that topic and based on this PR #3613 and the table which was created by @briandamaged (https://docs.google.com/spreadsheets/d/19TMouhxdIosYGzubO-2lbxm8Ykx4jR-Iu74HXohFYMg/edit#gid=0) I realised that this might be a bug which I think was introduced by PR #4122.

When having both cwd parameter and knexfile parameter, the knexfile
basepath overwrites the process cwd which is strange IMO.

If we pass cwd it should have higher precedence than the basepath of the
knexfile for process cwd selection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant