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

[TIMOB-23995] iOS: Add __dirname and __filename to the global app.js scope #10241

Merged
merged 4 commits into from Aug 10, 2018

Conversation

hansemannn
Copy link
Collaborator

JIRA: https://jira.appcelerator.org/browse/TIMOB-23995

Extended test-case to validate files require()'d can be found in the linked JIRA.

@build
Copy link
Contributor

build commented Aug 9, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

TiStringRef dirnameProperty = TiStringCreateWithCFString((CFStringRef) @"__dirname");
TiStringRef filenameProperty = TiStringCreateWithCFString((CFStringRef) @"__filename");
TiObjectSetProperty(jsContext, globalRef, dirnameProperty, [KrollObject toValue:kroll value:@"/"], kTiPropertyAttributeDontEnum | kTiPropertyAttributeReadOnly | kTiPropertyAttributeDontDelete, NULL);
TiObjectSetProperty(jsContext, globalRef, filenameProperty, [KrollObject toValue:kroll value:@"/app.js"], kTiPropertyAttributeDontEnum | kTiPropertyAttributeReadOnly | kTiPropertyAttributeDontDelete, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__filename should just be the filename, no /.

Copy link
Collaborator Author

@hansemannn hansemannn Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's with parity of the current implementation (for require'ish format). Then we should change it for both.

EDIT: It looks like node uses the full (absolute) path, interesting. How should we go?

Node example:
index.js

console.log('__filename = ' + __filename);

> node index.js:

__filename = /Users/hknoechel/Documents/dev/test_node/index.js

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hansemannn I'm sorry, I'm horribly mistaken. __filename is a full path. My bad.

Copy link
Contributor

@janvennemann janvennemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@hansemannn hansemannn merged commit 5fa08ed into tidev:master Aug 10, 2018
@hansemannn hansemannn modified the milestones: 7.4.0, 7.5.0 Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants