breaking: use platform config parser (#162)
diff --git a/lib/Api.js b/lib/Api.js
index 218288c..6eed49c 100644
--- a/lib/Api.js
+++ b/lib/Api.js
@@ -28,6 +28,7 @@
ConfigChanges: { PlatformMunger },
CordovaError,
CordovaLogger,
+ ConfigParser,
events: selfEvents,
PlatformJson,
PluginInfoProvider
@@ -93,6 +94,9 @@
}
prepare (cordovaProject, options) {
+ // Use Cordova Electron's Common Dependency
+ cordovaProject.projectConfig = new ConfigParser(cordovaProject.projectConfig.path);
+
return require('./prepare').prepare.call(this, cordovaProject, options);
}
diff --git a/tests/spec/unit/lib/Api.spec.js b/tests/spec/unit/lib/Api.spec.js
index b80e527..d32e61b 100644
--- a/tests/spec/unit/lib/Api.spec.js
+++ b/tests/spec/unit/lib/Api.spec.js
@@ -65,7 +65,7 @@
beforeAll(() => {
fs.ensureDirSync(tmpDir);
- fs.copySync(path.resolve(fixturesDir, 'testapp'), path.resolve(tmpDir, 'testapp'));
+ fs.copySync(path.resolve(fixturesDir, 'testapp'), testProjectDir);
apiEvents = Api.__get__('selfEvents');
apiEvents.addListener('verbose', (data) => { });
@@ -131,8 +131,21 @@
const prepare = jasmine.createSpy('prepare');
Api.__set__('require', () => ({ prepare }));
- api.prepare('', {});
- expect(prepare).toHaveBeenCalledWith(jasmine.any(String), jasmine.any(Object));
+
+ // Mock project configs coming from lib.
+ const appendProjectPath = (dirFile) => path.join(api.root, dirFile);
+ const project = {
+ root: api.root,
+ projectConfig: new ConfigParser(appendProjectPath('config.xml')),
+ locations: {
+ plugins: appendProjectPath('plugins'),
+ www: appendProjectPath('www'),
+ rootConfigXml: appendProjectPath('config.xml')
+ }
+ };
+
+ api.prepare(project, {});
+ expect(prepare).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Object));
Api.__set__('require', apiRequire);
});
});