-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 for relative paths on sequelize.import #901
Conversation
Can you update the description to provide an example on how to use it? |
Nice work! :) Any chance we can get a test for a file that doesn't exist / errors? :) |
@ricardograca its pretty self explanatory O_o its relative paths for importing instead of having to define an absolute path |
I know that and you know that, but some future user reading this pull-request may not know that :) But, yes, it's probably obvious. The docs will need updating though. |
Thanks for the feedback! Updated the description with examples. |
docs are in a separate repo - https://github.com/sequelize/sequelize-doc |
if (url.parse(path).pathname.indexOf('/') !== 0) { | ||
// make path relative to the caller | ||
var callerFilename = Utils.stack()[1].getFileName(); | ||
path = url.resolve(callerFilename, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more proper to use path.resolve for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry about that.
What variable name should "path" module be assigned to? Is "Path" ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me :-)
cool :) |
tests aren't running for me
|
Thanks for all the work on sequelize!
This patch makes this possible:
var Project = this.sequelize.import("assets/project")
or
var Project = this.sequelize.import("./assets/project")
where only
var Project = this.sequelize.import(__dirname + "/assets/project")
would work, previously (and still does).
I hope this contribution is usefull