Also search for app.asar when starting app.

This commit is contained in:
Cheng Zhao 2014-09-24 20:09:41 +08:00
parent e0c469183d
commit e5e1e207b6
2 changed files with 10 additions and 11 deletions

View file

@ -58,14 +58,15 @@ setImmediate ->
# Now we try to load app's package.json. # Now we try to load app's package.json.
packageJson = null packageJson = null
packagePath = path.join process.resourcesPath, 'app' searchPaths = [ 'app', 'app.asar', 'default_app' ]
try for packagePath in searchPaths
# First we try to load process.resourcesPath/app try
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'))) packagePath = path.join process.resourcesPath, packagePath
catch error packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
# If not found then we load browser/default_app catch e
packagePath = path.join process.resourcesPath, 'default_app' continue
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
throw new Error("Unable to find a valid app") unless packageJson?
# Set application's version. # Set application's version.
app = require 'app' app = require 'app'

View file

@ -77,10 +77,8 @@ Archive::~Archive() {
bool Archive::Init() { bool Archive::Init() {
base::File file(path_, base::File::FLAG_OPEN | base::File::FLAG_READ); base::File file(path_, base::File::FLAG_OPEN | base::File::FLAG_READ);
if (!file.IsValid()) { if (!file.IsValid())
PLOG(ERROR) << "Unable to open " << path_.value();
return false; return false;
}
std::vector<char> buf; std::vector<char> buf;
int len; int len;