Add node path and extra paths to env for build and run calls

This commit is contained in:
Martijn Walraven
2015-07-20 18:45:59 -07:00
parent 10a2741f76
commit 3a33b07b76
2 changed files with 17 additions and 7 deletions

View File

@@ -27,11 +27,11 @@ export default class iOSRunner extends CordovaRunner {
if (this.isDevice) {
openInXcode(files.pathJoin(this.cordovaProject.projectRoot, 'platforms', 'ios'));
} else {
let path = process.env.PATH || '.';
path += ':' + files.pathJoin(files.getCurrentToolsDir(), 'tools/node_modules/ios-sim/bin');
let env = options.env || {};
env.PATH = path;
return this.cordovaProject.run(this.platform, this.isDevice, _.extend(options, { env: env }));
const iosSimBinPath = files.convertToOSPath(
files.pathJoin(files.getCurrentToolsDir(),
'tools/node_modules/ios-sim/bin'));
return this.cordovaProject.run(this.platform, this.isDevice,
_.extend(options, { extraPaths: [iosSimBinPath] }));
}
}

View File

@@ -61,6 +61,11 @@ export default class CordovaProject {
return { silent: !Console.verbose, verbose: Console.verbose };
}
get defaultPaths() {
const nodeBinDir = files.convertToOSPath(files.getCurrentNodeBinDir());
return [nodeBinDir];
}
// Platforms
getInstalledPlatforms() {
@@ -229,7 +234,9 @@ export default class CordovaProject {
async build(options) {
this.chdirToProjectRoot();
options =_.extend(this.defaultOptions, options);
const extraPaths = (this.defaultPaths || []).unshift(options.extraPaths);
const env = files.currentEnvWithPathsAdded(extraPaths);
options = _.extend(this.defaultOptions, options, { env: env });
return await cordova.raw.build(options);
}
@@ -238,7 +245,10 @@ export default class CordovaProject {
async run(platform, isDevice, options) {
this.chdirToProjectRoot();
options =_.extend(this.defaultOptions, { platforms: [platform] }, options);
const extraPaths = (this.defaultPaths || []).unshift(options.extraPaths);
const env = files.currentEnvWithPathsAdded(extraPaths);
options = _.extend(this.defaultOptions, options, { env: env },
{ platforms: [platform] });
if (isDevice) {
return await cordova.raw.run(options);