Skip to content
Permalink
Browse files
fix(cordova/util): version detection for legacy platforms (#856)
The new meachanism introduced in #815 relied on all platforms exporting
their version in their version script. This is not the case for the
browser platform though. Thus we need to revert to spawning an external
process for legacy platforms unfortunately.
  • Loading branch information
raphinesse committed Sep 24, 2020
1 parent 6a10954 commit 0f4389d0160159a4a5c8f181e30c0d7ce35afd77
Showing 2 changed files with 17 additions and 3 deletions.
@@ -107,6 +107,19 @@ describe('util module', function () {
.then(versions => expect(versions[PLATFORM]).toBe('9.0.0'));
});
});
describe('getPlatformVersion method', () => {
it('should get the version from a legacy platform', () => {
const PLATFORM_VERSION = '1.2.3-dev';

fs.outputFileSync(path.join(temp, 'cordova/version'), `
#!/usr/bin/env node
console.log('${PLATFORM_VERSION}');
`.trim());

const version = util.getPlatformVersion(temp);
expect(version).toBe(PLATFORM_VERSION);
});
});
describe('findPlugins method', function () {
let pluginsDir, plugins;

@@ -207,9 +207,10 @@ function getPlatformVersion (platformPath) {
).version();
} catch (e) {
// Platforms pre-Cordova 10
return requireNoCache(
path.join(platformPath, 'cordova/version')
).version;
return require('execa').sync(
process.argv0, // node
[path.join(platformPath, 'cordova/version')]
).stdout;
}
}

0 comments on commit 0f4389d

Please sign in to comment.