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
Conversation
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); |
There was a problem hiding this comment.
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 /
.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
JIRA: https://jira.appcelerator.org/browse/TIMOB-23995
Extended test-case to validate files
require()
'd can be found in the linked JIRA.