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

knex cli tool doesn't take --cwd option #326

Closed
SohumB opened this Issue Jun 16, 2014 · 6 comments

Comments

Projects
None yet
3 participants
@SohumB
Copy link
Contributor

SohumB commented Jun 16, 2014

There's code to read it from argv.cwd, but you can't specify it - it goes error: unknown option --cwd. We kinda need it, because we don't want the working directory to change when we run knex.

@tkellen

This comment has been minimized.

Copy link
Collaborator

tkellen commented Jun 16, 2014

This is fixed in #327 but you can solve this problem now by using the --knexfile option, passing the full path to your knexfile.

@SohumB

This comment has been minimized.

Copy link
Contributor Author

SohumB commented Jun 16, 2014

No, you can't, actually - if you specify a knexfile in a different
directory, it chdirs to that directory... for some reason.

Thanks for the fix!
On Jun 17, 2014 12:06 AM, "Tyler Kellen" notifications@github.com wrote:

This is fixed in #327 #327 but
you can solve this problem now by using the --knexfile option, passing
the full path to your knexfile.


Reply to this email directly or view it on GitHub
#326 (comment).

@tgriesser

This comment has been minimized.

Copy link
Owner

tgriesser commented Jun 16, 2014

@tkellen what was the reason again for switching directories here?

Was it something that doesn't apply to the way that I'm probably improperly using liftoff here :)

@tkellen

This comment has been minimized.

Copy link
Collaborator

tkellen commented Jun 16, 2014

Liftoff has typically been used to handle configuration files for task runners. In that context, consumers usually want the process to chdir to the directory of the config, that way all file operations are performed relative to it. You might consider removing that from here:
https://github.com/tgriesser/knex/blob/master/lib/bin/cli.js#L152-L155

...but don't think I would. @SohumB, what is the use case that drives the need for the process to not chdir? It sounds like you should be invoking migrations programmatically rather than calling out to the CLI.

@SohumB

This comment has been minimized.

Copy link
Contributor Author

SohumB commented Jun 16, 2014

The usecase is that we use a different set of config-munging libraries that step in before knex even sees the knexfile, and the path specified is relative to the cwd for them. You're probably right, we probably should be running this programmatically.

@tkellen

This comment has been minimized.

Copy link
Collaborator

tkellen commented Jun 16, 2014

Definitely sounds like a case for using the migration API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.