Skip to content

Commit

Permalink
Replace dependency on cordova-lib with xml2js.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpa99c committed Aug 9, 2019
1 parent 717126d commit a74c04c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
},
"dependencies": {
"xcode": "^2.0.0",
"cordova-lib":"^9.0.0"
"xml2js": "^0.4.16"
}
}
5 changes: 3 additions & 2 deletions scripts/after_prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ module.exports = function (context) {
utilities.copyKey(PLATFORM.IOS);

var helper = require("./ios/helper");
var xcodeProjectPath = helper.getXcodeProjectPath(context);
helper.ensureRunpathSearchPath(context, xcodeProjectPath);
helper.getXcodeProjectPath(function(xcodeProjectPath){
helper.ensureRunpathSearchPath(context, xcodeProjectPath);
});
}
if (platforms.indexOf('android') !== -1 && utilities.directoryExists(ANDROID_DIR)) {
console.log('Preparing Firebase on Android');
Expand Down
7 changes: 4 additions & 3 deletions scripts/ios/after_plugin_install.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module.exports = function(context) {

// Add a build phase which runs a shell script that executes the Crashlytics
// run command line tool which uploads the debug symbols at build time.
var xcodeProjectPath = helper.getXcodeProjectPath(context);
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
helper.addShellScriptBuildPhase(context, xcodeProjectPath);
helper.getXcodeProjectPath(function(xcodeProjectPath){
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
helper.addShellScriptBuildPhase(context, xcodeProjectPath);
});
};
5 changes: 3 additions & 2 deletions scripts/ios/before_plugin_uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var helper = require("./helper");
module.exports = function(context) {

// Remove the build script that was added when the plugin was installed.
var xcodeProjectPath = helper.getXcodeProjectPath(context);
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
helper.getXcodeProjectPath(function(xcodeProjectPath){
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
});
};
12 changes: 4 additions & 8 deletions scripts/ios/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ module.exports = {

/**
* Used to get the path to the XCode project's .pbxproj file.
*
* @param {object} context - The Cordova context.
* @returns The path to the XCode project's .pbxproj file.
*/
getXcodeProjectPath: function (context) {

var appName = utilities.getAppName(context);

return path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj");
getXcodeProjectPath: function (cb) {
utilities.getAppName(function(appName){
cb(path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj"));
});
},

/**
Expand Down
13 changes: 6 additions & 7 deletions scripts/lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
var fs = require('fs');
var path = require("path");
var xml2js = require('xml2js').parseString;

fs.ensureDirSync = function (dir) {
if (!fs.existsSync(dir)) {
Expand All @@ -19,14 +20,12 @@ fs.ensureDirSync = function (dir) {
module.exports = {
/**
* Used to get the name of the application as defined in the config.xml.
*
* @param {object} context - The Cordova context.
* @returns {string} The value of the name element in config.xml.
*/
getAppName: function (context) {
var ConfigParser = require("cordova-lib").configparser;
var config = new ConfigParser("config.xml");
return config.name();
getAppName: function(cb){
var xml = fs.readFileSync("config.xml", 'utf-8');
xml2js(xml, function(err, result){
cb(result.widget.name[0]);
});
},

/**
Expand Down

0 comments on commit a74c04c

Please sign in to comment.