Skip to content

Commit

Permalink
refactor: replace installation instructions involving android binary
Browse files Browse the repository at this point in the history
  • Loading branch information
raphinesse committed Nov 19, 2020
1 parent a293601 commit caf8a3e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 29 deletions.
20 changes: 1 addition & 19 deletions bin/templates/cordova/lib/check_reqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,6 @@ module.exports.check_android = function () {
});
};

// TODO: is this actually needed?
module.exports.getAbsoluteAndroidCmd = function () {
var cmd = forgivingWhichSync('android');
if (cmd.length === 0) {
cmd = forgivingWhichSync('sdkmanager');
}
if (module.exports.isWindows()) {
return '"' + cmd + '"';
}
return cmd.replace(/(\s)/g, '\\$1');
};

module.exports.check_android_target = function (originalError) {
// valid_target can look like:
// android-19
Expand All @@ -346,13 +334,7 @@ module.exports.check_android_target = function (originalError) {
if (targets.indexOf(desired_api_level) >= 0) {
return targets;
}
var androidCmd = module.exports.getAbsoluteAndroidCmd();
var msg = 'Please install Android target / API level: "' + desired_api_level + '".\n\n' +
'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +
'You will require:\n' +
'1. "SDK Platform" for API level ' + desired_api_level + '\n' +
'2. "Android SDK Platform-tools (latest)\n' +
'3. "Android SDK Build-tools" (latest)';
var msg = `Please install the Android SDK Platform "platforms;${desired_api_level}"`;
if (originalError) {
msg = originalError + '\n' + msg;
}
Expand Down
6 changes: 1 addition & 5 deletions bin/templates/cordova/lib/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,7 @@ module.exports.start = function (emulator_ID, boot_timeout) {
return best.name;
}

var androidCmd = check_reqs.getAbsoluteAndroidCmd();
return Promise.reject(new CordovaError('No emulator images (avds) found.\n' +
'1. Download desired System Image by running: ' + androidCmd + ' sdk\n' +
'2. Create an AVD by running: ' + androidCmd + ' avd\n' +
'HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver\n'));
return Promise.reject(new CordovaError('No emulator images (avds) found'));
});
}).then(function (emulatorId) {
return self.get_available_port().then(function (port) {
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/check_reqs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe('check_reqs', function () {
fail('Expected promise to be rejected');
}, err => {
expect(err).toEqual(jasmine.any(Error));
expect(err.message).toContain('Please install Android target');
expect(err.message).toContain('Please install the Android SDK Platform');
});
});
});
Expand Down
4 changes: 0 additions & 4 deletions spec/unit/emulator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ describe('emulator', () => {
const port = 5555;
let emulator;
let AdbSpy;
let checkReqsSpy;
let execaSpy;
let whichSpy;

Expand All @@ -233,9 +232,6 @@ describe('emulator', () => {
AdbSpy.shell.and.returnValue(Promise.resolve());
emu.__set__('Adb', AdbSpy);

checkReqsSpy = jasmine.createSpyObj('create_reqs', ['getAbsoluteAndroidCmd']);
emu.__set__('check_reqs', checkReqsSpy);

execaSpy = jasmine.createSpy('execa').and.returnValue(
jasmine.createSpyObj('spawnFns', ['unref'])
);
Expand Down

0 comments on commit caf8a3e

Please sign in to comment.