Skip to content

Commit

Permalink
plugin: set NODE_PATH to include the project root
Browse files Browse the repository at this point in the history
  • Loading branch information
enricogior authored and jaimecbernardo committed Jan 26, 2018
1 parent c200f28 commit d478d02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void run() {
"-e",
scriptToRun
},
builtinModulesPath,
nodeJsProjectPath + ":" + builtinModulesPath,
redirectOutputToLogcat
);
}
Expand All @@ -158,7 +158,7 @@ public void run() {
startNodeWithArguments(new String[]{"node",
nodeJsProjectPath + "/" + mainFileName
},
builtinModulesPath,
nodeJsProjectPath + ":" + builtinModulesPath,
redirectOutputToLogcat
);
}
Expand Down
13 changes: 9 additions & 4 deletions ios/RNNodeJsMobile.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ @implementation RNNodeJsMobile

NSString* const BUILTIN_MODULES_RESOURCE_PATH = @"builtin_modules";
NSString* const NODEJS_PROJECT_RESOURCE_PATH = @"nodejs-project";
NSString* nodePath;

@synthesize bridge = _bridge;

Expand All @@ -28,6 +29,12 @@ - (id)init
{
[[NodeRunner sharedInstance] setCurrentRNNodeJsMobile:self];
}

NSString* builtinModulesPath = [[NSBundle mainBundle] pathForResource:BUILTIN_MODULES_RESOURCE_PATH ofType:@""];
nodePath = [[NSBundle mainBundle] pathForResource:NODEJS_PROJECT_RESOURCE_PATH ofType:@""];
nodePath = [nodePath stringByAppendingString:@":"];
nodePath = [nodePath stringByAppendingString:builtinModulesPath];

return self;
}

Expand All @@ -42,26 +49,24 @@ - (id)init

-(void)callStartNodeWithScript:(NSString *)script
{
NSString* builtinModulesPath = [[NSBundle mainBundle] pathForResource:BUILTIN_MODULES_RESOURCE_PATH ofType:@""];
NSArray* nodeArguments = [NSArray arrayWithObjects:
@"node",
@"-e",
script,
nil
];
[[NodeRunner sharedInstance] startEngineWithArguments:nodeArguments:builtinModulesPath];
[[NodeRunner sharedInstance] startEngineWithArguments:nodeArguments:nodePath];
}

-(void)callStartNodeProject:(NSString *)mainFileName
{
NSString* builtinModulesPath = [[NSBundle mainBundle] pathForResource:BUILTIN_MODULES_RESOURCE_PATH ofType:@""];
NSString* srcPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@/%@", NODEJS_PROJECT_RESOURCE_PATH, mainFileName] ofType:@""];
NSArray* nodeArguments = [NSArray arrayWithObjects:
@"node",
srcPath,
nil
];
[[NodeRunner sharedInstance] startEngineWithArguments:nodeArguments:builtinModulesPath];
[[NodeRunner sharedInstance] startEngineWithArguments:nodeArguments:nodePath];
}


Expand Down

0 comments on commit d478d02

Please sign in to comment.