[TIMOB-16004] iOS: Expose current file path and directory path to commonjs module scope
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-05-09T22:30:30.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2014 Sprint 09, 2014 Sprint 09 SDK, Release 3.3.0 |
Components | iOS |
Labels | module_filesystem, qe-closed-3.3.0, qe-testadded |
Reporter | Christian Sullivan |
Assignee | Sabil Rahim |
Created | 2013-12-17T02:58:11.000+0000 |
Updated | 2014-09-05T14:27:22.000+0000 |
Description
__filename and __dirname are available in android but not on ios.
Attachments
File | Date | Size |
---|---|---|
Resources.zip | 2014-05-09T22:28:30.000+0000 | 3434 |
PR [MASTER] https://github.com/appcelerator/titanium_mobile/pull/5131
[~mxia] I have added the blocked ticket to this ticket. This is needed to properly resolve the file being required when
..
or./
is used in the path of the required module. Example If the below example is used it will throw an error when using liveviewCurrently only the absolute path will work.
With my pr it will add the __dirname and __filename vars that will make it possible to determine what the modules absolute path is. It will also bring it to parity to android's and ios's commonjs implementation.
[~mxia] can we get TIMOB-16011 merged in now?
I'm reviewing this and I'm not sure that it does it the expected way. I have a file "a.js" in the Resources directory, this is the result of "__dirname"
Should it be that or this: "/"?
Update, On Android the file "a.js" located in the root of the Resources, when asked for "__dirname" it returns this:
On iOS it returns this:
PR https://github.com/appcelerator/titanium_mobile/pull/5641
Missed the boat for 3.3.0. Will pull into 3.4.0.
Attaching Resources for test case
PR merged
Verified the fix on: iOS simulator: 7.1 SDK: 3.3.0.v20140515151935 CLI version : 3.3.0-dev OS : MAC OSX 10.9.2 Alloy: 1.4.0-Alpha ACS: 1.0.14 npm:1.3.2 LiveView: 1.0.4 Appcelerator Studio, build: 3.3.0.201405121247 titanium-code-processor: 1.1.1 XCode : 5.1.1