gagle / node-properties

.properties parser/stringifier.
MIT License
133 stars 42 forks source link

"../a/b" doesn't work #10

Closed JasonBoy closed 10 years ago

JasonBoy commented 10 years ago

I have a file structure like a (folder) -- a.properties b (folder) -- b.js I read the properties file in b.js , I use the path with '../a/a.properties', but actually it doesnot work, I need to use absolute path, is there any way to fix that, or I write it in wrong way

gagle commented 10 years ago

Post your code because this is working correctly:

properties.parse ("../a/a.properties", { path:true }, function (error, data){ ... });

How are you executing the node program?

JasonBoy commented 10 years ago

I have a app.js in the root dir, 'node app.js' , looks this path should still be releative to the path of app.js, not the path of b.js

gagle commented 10 years ago

If you need to use an absolute path then you have something wrong in the directory tree or in the relative path. The path is forwarded to the fs.readFile() function, I'm not doing anything weird with it.

https://github.com/gagle/node-properties/blob/master/lib/read.js#L472

Also node app.js uses a different current working directory than node dir/app.js, so be aware of this subtle things.

gagle commented 10 years ago

Closing this... it seems that it was an issue not directly related with the lib.