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

Relative/absolute paths #26

Open
smart--petea opened this issue Sep 24, 2014 · 0 comments
Open

Relative/absolute paths #26

smart--petea opened this issue Sep 24, 2014 · 0 comments

Comments

@smart--petea
Copy link
Contributor

There are different situations in work with relative and absolute paths. I didn't find an approach based only on process.cwd() or __dirname. Either of this two function has wrong situations.

In my tests, problem was:

  1. relative path are defined in test folder
  2. source code of vatican is in other place (process.cwd() is used in vatican.js)

If I'm in test folder and I call

mocha file.js

or

node file.js

all will be ok because `process.cwd()' point to test folder.

If I'm not in test folder and call

mocha test/file.js

or

node test/file.js

then the workflow will fail because process.cwd() point to other folder, from wich we call.

__dirname can help only if it is used in file.js (this is not the case of relative paths).

Express.js framework, in tests, does not use relative paths.

Webpack (http://webpack.github.io/docs/configuration.html ) has an interesting approach

  1. there is an option which indicate to folder with datas by an absolute path (only absolute). If this option is not setted the path is considered equal to process.cwd()
  2. other paths from project are used directly if they are absolute and are computed from path from point 1 if they are relative.

A strategy in working with paths is very important because if project is called by crontab then this issue will raise again.

This was referenced Oct 1, 2014
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

1 participant