Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
fixed mode switch
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Apr 6, 2016
2 parents 9e95cec + 9f6edc7 commit 1ae029f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Requires electron version 0.37.2
To run mist in development you need [Node.js NPM](https://nodejs.org) and [Meteor](https://www.meteor.com/install) and electron installed:

$ curl https://install.meteor.com/ | sh
$ npm install -g electron-prebuilt
$ npm install -g electron-prebuilt@0.37.2

### Installation

Expand Down Expand Up @@ -71,7 +71,7 @@ In the original window you can then start Mist with:

### Run the Wallet

Switch the `global.mode` to `"wallet"` in the `main.js`.
Add `--mode wallet` to the Mist command-line.

Start the wallet app for development, *in a separate terminal window:*

Expand All @@ -84,7 +84,7 @@ Start the wallet app for development, *in a separate terminal window:*
In the original window you can then start Mist with:

$ cd mist
$ electron .
$ electron . --mode wallet


### Using Mist with a privatenet
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ gulp.task('copy-files', ['clean:dist'], function() {
gulp.task('switch-production', ['clean:dist'], function() {
return gulp.src(['./main.js'])
.pipe(replace('global.production = false;', 'global.production = true;'))
.pipe(replace('global.mode = \''+ (type === 'mist' ? 'wallet' : 'mist') +'\';', 'global.mode = \''+ type +'\';'))
.pipe(replace('global.mode = (argv.mode ? argv.mode : \'mist\');', 'global.mode = (argv.mode ? argv.mode : \''+ type +'\');'))
.pipe(gulp.dest('./dist_'+ type +'/app'));
});

Expand Down
28 changes: 27 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ const dialog = require('dialog');
const packageJson = require('./package.json');
const i18n = require('./modules/i18n.js');

// CLI options
const argv = require('yargs')
.usage('Usage: $0 [options]')
.describe('version', 'Display app version')
.describe('mode', 'App mode: wallet, mist (default)')
.describe('gethpath', 'Path to geth executable to use instead of default')
.describe('ethpath', 'Path to eth executable to use instead of default')
.describe('ignore-gpu-blacklist', 'Ignores GPU blacklist (needed for some Linux installations)')
.alias('m', 'mode')
.help('h')
.alias('h', 'help')
.parse(process.argv.slice(1));

if (argv.version) {
console.log(packageJson.version);
process.exit(0);
}

if (argv.ignoreGpuBlacklist) {
app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true');
}

// GLOBAL Variables
global.path = {
Expand All @@ -23,7 +44,12 @@ global.path = {
global.appName = 'Mist';

global.production = false;
global.mode = 'wallet';

global.mode = ('wallet' === argv.mode ? 'wallet' : 'mist');
global.paths = {
geth: argv.gethpath,
eth: argv.ethpath,
};

global.version = packageJson.version;
global.license = packageJson.license;
Expand Down
51 changes: 35 additions & 16 deletions modules/getNodePath.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

/**
Gets the right Node path
Expand All @@ -7,28 +9,45 @@ Gets the right Node path
const path = require('path');
const binaryPath = path.resolve(__dirname + '/../nodes');

// cache
const resolvedPaths = {};


module.exports = function(type) {
if (resolvedPaths[type]) {
return resolvedPaths[type];
}

let ret = '';

// global override?
if (global.paths && global.paths[type]) {
resolvedPaths[type] = global.paths[type];
} else {
var binPath = (global.production)
? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type
: binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type;

if(global.production) {
binPath = binPath.replace('app.asar/','').replace('app.asar\\','');

if(process.platform === 'darwin') {
binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/'));
}
}

var binPath = (global.production)
? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type
: binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type;

if(global.production) {
binPath = binPath.replace('app.asar/','').replace('app.asar\\','');

if(process.platform === 'darwin') {
binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/'));
if(process.platform === 'win32') {
binPath = binPath.replace(/\/+/,'\\');
binPath += '.exe';
}

resolvedPaths[type] = binPath;
}

console.log(`Resolved path for ${type}: ${resolvedPaths[type]}`);

if(process.platform === 'win32') {
binPath = binPath.replace(/\/+/,'\\');
binPath += '.exe';
}
return resolvedPaths[type];
};

// if(process.platform === 'linux')
// binPath = type; // simply try to run a global binary

return binPath;
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"os-timesync": "^1.0.3",
"solc": "^0.3.1-1",
"underscore": "^1.8.3",
"web3": "^0.15.1"
"web3": "^0.15.1",
"yargs": "^4.3.1"
},
"devDependencies": {
"del": "^1.2.1",
Expand Down

0 comments on commit 1ae029f

Please sign in to comment.