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

Meteor.rootPath and Meteor.absolutePath are the same on Windows #3

Closed
Konard opened this issue Mar 22, 2016 · 16 comments
Closed

Meteor.rootPath and Meteor.absolutePath are the same on Windows #3

Konard opened this issue Mar 22, 2016 · 16 comments

Comments

@Konard
Copy link
Contributor

Konard commented Mar 22, 2016

Both Meteor.rootPath and Meteor.absolutePath returns full path to 'programs/server' on Windows (meteor 1.2.1).

This is because final paths on Windows use \\ instead of / for folder separator. And split('/.meteor') no longer finds any '/.meteor' in resulting path.

So it is better to use path.sep in path.sep + '.meteor' as the result argument for split function.

So the possible solution is to change:

Meteor.absolutePath = __meteor_bootstrap__.serverDir.split('/.meteor')[0]; (https://github.com/VeliovGroup/Meteor-root/blob/c2978b2dd76248156aef97541905e11fa1ed1fcf/meteor-root.js#L2)

to

var path = Npm.require('path');
Meteor.absolutePath = __meteor_bootstrap__.serverDir.split(path.sep + '.meteor')[0];

or

var path = Npm.require('path');
Meteor.absolutePath = path.resolve('.').split(path.sep + '.meteor')[0];

Looks like __meteor_bootstrap__.serverDir is equal to path.resolve('.') and process.cwd().

More at: http://stackoverflow.com/questions/18378809/find-absolute-base-path-of-the-project-directory-after-meteor-0-6-5/35948996#35948996
And: http://stackoverflow.com/questions/18378809/find-absolute-base-path-of-the-project-directory-after-meteor-0-6-5/35948996#comment59967680_32658007

@dr-dimitru
Copy link
Member

Would you run tests and send PR? Otherwise I can do it myself, but later

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

I updated the issue description. path.sep is required to solve the issue.

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

Ok, I`ll try to make a PR.

@dr-dimitru
Copy link
Member

@Konard
Why not use Regular Expression?

Meteor.absolutePath = __meteor_bootstrap__.serverDir.split(/(\\|\/).meteor/)[0];

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

For me it looks like the best solution is:

var path = Npm.require('path');
Meteor.absolutePath = path.resolve('.').split(path.sep + '.meteor')[0];

__meteor_bootstrap__ requires bootstrap package.
path.sep can be extended in future with other file systems / platforms.

But Meteor.absolutePath = __meteor_bootstrap__.serverDir.split(/(\\|\/).meteor/)[0]; can also be good enough if bootstrap included to the project.

@dr-dimitru
Copy link
Member

isn't __meteor_bootstrap__ always presented?

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

Trying to run meteor test-packages but it does not work. https://ide.c9.io/konard/meteor-root (cloned your repository here). How do you run Tinytest?

@dr-dimitru
Copy link
Member

In project's directory run:

meteor test-packages ./

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

konard:~/workspace (master) $ meteor test-packages ./
[[[[[ Tests ]]]]]                             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3000/

This is what I get. No output in console.

@dr-dimitru
Copy link
Member

First visit http://localhost:3000/

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

I actually cannot do it. I have only access to ssh. And to 8080, 8081, 8082 ports from the internet.

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

Ah. meteor test-packages \. --port 8080 works. https://meteor-root-konard.c9users.io/ is live now.

@dr-dimitru
Copy link
Member

  1. Why not do it locally?
  2. Forward some port, to 8080

I see you've solved it

@Konard
Copy link
Contributor Author

Konard commented Mar 22, 2016

This code have the same results as current version (https://github.com/VeliovGroup/Meteor-root/blob/c2978b2dd76248156aef97541905e11fa1ed1fcf/meteor-root.js):

var path = Npm.require('path');
Meteor.rootPath     = path.resolve('.');
Meteor.absolutePath = Meteor.rootPath.split(path.sep + '.meteor')[0];

And the only changes required are these 3 lines. It works on windows too (tested).

@dr-dimitru
Copy link
Member

dr-dimitru commented Mar 23, 2016

Published as v1.0.3, also available via Atmosphere.

Thank you for contribution @Konard
If you found this package useful, please do not hesitate to star it at both GitHub and Atmosphere. Also you may like to Tweet about it or share at Facebook

Sorry for off-topic, but I saw you has knowledge in Traditional Chinese, if it's true, let me know if you're interested in translating interfaces, we're looking for help with next languages:

  • French;
  • German;
  • Spanish;
  • Chinese.

And preferred way and time to contact you.

@Konard
Copy link
Contributor Author

Konard commented Mar 23, 2016

@dr-dimitru contact me direclty using vk or skype on this topic please.
P.S. Yes, I planned to star the project as soon as I can use it. https://github.com/linksplatform/Crawler (this project was a reason, I've started looking for a stable solution), and now meteor-root is integrated with it linksplatform/Crawler@e2f1a81.

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

No branches or pull requests

2 participants