Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Use the correct JavaScript environment search path dir
Browse files Browse the repository at this point in the history
The directory was not being set correctly for packaged builds.  In particular base::DIR_SOURCE_ROOT was returning a directory that wasn't correct.   In dev builds it would return /Users/bbondy/projects/brave/browser-laptop-bootstrap/src/browser-laptop and in packaged builds that were run from /Users/bbondy/projects/brave/browser-laptop-bootstrap/src/browser-laptop/Brave-darwin-x64/Brave.app it would return /Users/bbondy/projects/brave/browser-laptop-bootstrap/src/.

To fix this I just use the resource path's app.asar file if it exists first and only fallback to the search path if that doesn't exist since it only exists in packaged builds.

Fix brave/browser-laptop#8195

Auditors: @bridiver
  • Loading branch information
bbondy authored and bridiver committed Apr 12, 2017
1 parent d98bb5a commit 6f901bc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions atom/browser/javascript_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ std::vector<base::FilePath> GetModuleSearchPaths() {

auto command_line = base::CommandLine::ForCurrentProcess();
base::FilePath source_root = command_line->GetSwitchValuePath("source-root");
if (source_root.empty() &&
!base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root)) {
if (source_root.empty()) {
source_root = GetResourcesDir().Append(FILE_PATH_LITERAL("app.asar"));
}

if (base::PathExists(source_root)) {
bool path_exists = base::PathExists(source_root);
if (!path_exists) {
base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root);
path_exists = base::PathExists(source_root);
}

if (path_exists) {
search_paths.push_back(source_root);
search_paths.push_back(source_root.Append(FILE_PATH_LITERAL("app")));
search_paths.push_back(source_root
Expand Down

0 comments on commit 6f901bc

Please sign in to comment.