Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25028] Fix issue where node-ios-device is not hoisted #9260

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 25 additions & 9 deletions build/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,31 @@ Packager.prototype.package = function (next) {
}.bind(this),
// Now include all the pre-built node-ios-device bindings/binaries
function (cb) {
if (this.targetOS == 'osx') {
exec('node bin/download-all.js', {cwd: path.join(this.zipSDKDir, 'node_modules', 'node-ios-device')}, function (err, stdout, stderr) {
if (err) {
console.log(stdout);
console.error(stderr);
return cb(err);
}
cb();
});
if (this.targetOS === 'osx') {
console.log(path.join(this.zipSDKDir, 'node_modules', 'node-ios-device'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the console.log() debug? It should probably be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

const hoistedPath = path.join(this.zipSDKDir, 'node_modules', 'node-ios-device');
const normalPath = path.join(this.zipSDKDir, 'node_modules', 'ioslib', 'node_modules', 'node-ios-device');
if (fs.existsSync(hoistedPath)) {
exec('node bin/download-all.js', {cwd: hoistedPath}, function (err, stdout, stderr) {
if (err) {
console.log(stdout);
console.error(stderr);
return cb(err);
}
cb();
});
} else if (fs.existsSync(normalPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a lot of duplicate code. It can be simplified:

let dir = path.join(this.zipSDKDir, 'node_modules', 'node-ios-device');

if (!fs.existsSync(dir)) {
    dir = path.join(this.zipSDKDir, 'node_modules', 'ioslib', 'node_modules', 'node-ios-device');
}

if (!fs.existsSync(dir)) {
    return cb(new Error('Unable to find node-ios-device module'));
}

exec('node bin/download-all.js', { cwd: dir, stdio: 'inherit' }, cb);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my bad I was thinking that it could be better as I wrote it, updated. I kept the exec usage similar to the others throughout the file,

exec('node bin/download-all.js', {cwd: normalPath}, function (err, stdout, stderr) {
if (err) {
console.log(stdout);
console.error(stderr);
return cb(err);
}
cb();
});
} else {
return cb(new Error('Unable to find node-ios-device module'))
}
} else {
cb();
}
Expand Down