Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16004] iOS: Expose current file path and directory path to commonjs module scope

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-05-09T22:30:30.000+0000
Affected Version/sn/a
Fix Version/s2014 Sprint 09, 2014 Sprint 09 SDK, Release 3.3.0
ComponentsiOS
Labelsmodule_filesystem, qe-closed-3.3.0, qe-testadded
ReporterChristian Sullivan
AssigneeSabil Rahim
Created2013-12-17T02:58:11.000+0000
Updated2014-09-05T14:27:22.000+0000

Description

__filename and __dirname are available in android but not on ios.

Attachments

FileDateSize
Resources.zip2014-05-09T22:28:30.000+00003434

Comments

  1. Christian Sullivan 2013-12-17

    PR [MASTER] https://github.com/appcelerator/titanium_mobile/pull/5131
  2. Christian Sullivan 2014-01-09

    [~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 liveview
       var x = require('../x');
       
    Currently only the absolute path will work.
       var x = require('/lib/x');
       
    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.
  3. Christian Sullivan 2014-02-13

    [~mxia] can we get TIMOB-16011 merged in now?
  4. Pedro Enrique 2014-04-17

    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"
       file:///Users/penrique/Library/Application%20Support/iPhone%20Simulator/7.1-64/Applications/34C10A38-31A4-4850-8211-336EFD27FB06/Titanium.app
       
    Should it be that or this: "/"?
  5. Pedro Enrique 2014-04-17

    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:
       file:///Users/penrique/Library/Application%20Support/iPhone%20Simulator/7.1-64/Applications/34C10A38-31A4-4850-8211-336EFD27FB06/Titanium.app
       
  6. Pedro Enrique 2014-04-22

    PR https://github.com/appcelerator/titanium_mobile/pull/5641
  7. Ingo Muschenetz 2014-04-28

    Missed the boat for 3.3.0. Will pull into 3.4.0.
  8. Vishal Duggal 2014-05-09

    Attaching Resources for test case
  9. Vishal Duggal 2014-05-09

    PR merged
  10. Paras Mishra 2014-05-16

    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

JSON Source