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

support for relative paths on sequelize.import #901

Merged
merged 2 commits into from
Sep 20, 2013
Merged

support for relative paths on sequelize.import #901

merged 2 commits into from
Sep 20, 2013

Conversation

accerqueira
Copy link
Contributor

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

@ricardograca
Copy link
Contributor

Can you update the description to provide an example on how to use it?

@durango
Copy link
Member

durango commented Sep 12, 2013

Nice work! :) Any chance we can get a test for a file that doesn't exist / errors? :)

@durango
Copy link
Member

durango commented Sep 12, 2013

@ricardograca its pretty self explanatory O_o its relative paths for importing instead of having to define an absolute path

@ricardograca
Copy link
Contributor

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.

@accerqueira
Copy link
Contributor Author

Thanks for the feedback! Updated the description with examples.
I looked for docs to update, but couldn't find... can you point me in the right direction?

@selfcontained
Copy link
Contributor

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);
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me :-)

@sdepold
Copy link
Member

sdepold commented Sep 20, 2013

cool :)

@sdepold
Copy link
Member

sdepold commented Sep 20, 2013

tests aren't running for me

Cannot find module '/Users/sdepold/Projects/sequelize/test/sequelize.test.js/assets/project'

@sdepold sdepold merged commit fa069ec into sequelize:master Sep 20, 2013
@accerqueira accerqueira deleted the feature/import-relpath branch September 20, 2013 23:39
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.

6 participants