Skip to content

Commit

Permalink
fix(restore-util): properly support long and short platform names (#880)
Browse files Browse the repository at this point in the history
* fix(GH-878): Fix platform restoration from package.json

* fix(restore-util): support long and short platform names

i.e. both <PLATFORM> and cordova-<PLATFORM>

Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
  • Loading branch information
breautek and raphinesse committed Sep 26, 2021
1 parent 33ce4fe commit 2093004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions spec/cordova/restore-util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ describe('cordova/restore-util', () => {
});
});

it('Test#007 : should find platform spec', () => {
setPkgJson('cordova.platforms', ['android']);
setPkgJson('devDependencies', {
'cordova-android': '1.0.0'
});

return restore.installPlatformsFromConfigXML(['android'], {}).then(() => {
expect(cordovaPlatform.add).toHaveBeenCalledWith(
jasmine.anything(),
jasmine.anything(),
['android@1.0.0'],
jasmine.anything()
);
});
});

it('Test#016 : should restore platforms & plugins and create a missing package.json', () => {
getCfg()
.addEngine(testPlatform)
Expand Down
2 changes: 1 addition & 1 deletion src/cordova/restore-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function installPlatformsFromConfigXML (platforms, opts) {

const platformInfo = platformIDs.map(plID => ({
name: plID,
spec: specs[plID]
spec: specs[`cordova-${plID}`] || specs[plID]
}));

let platformName = '';
Expand Down

0 comments on commit 2093004

Please sign in to comment.