diff --git a/install/hooks/android/after-prepare-build-node-assets-lists.js b/install/hooks/android/after-prepare-build-node-assets-lists.js index 5cf7578..3bed89d 100644 --- a/install/hooks/android/after-prepare-build-node-assets-lists.js +++ b/install/hooks/android/after-prepare-build-node-assets-lists.js @@ -50,16 +50,13 @@ module.exports = function(context) { return; } - var Q = context.requireCordovaModule('q'); - var deferral = new Q.defer(); - - createFileAndFolderLists(context, function(err) { - if (err) { - deferral.reject(err); - } else { - deferral.resolve(); - } + return new Promise((resolve, reject) => { + createFileAndFolderLists(context, function(err) { + if (err) { + reject(err); + } else { + resolve(); + } + }); }); - - return deferral.promise; } diff --git a/install/hooks/android/before-plugin-install.js b/install/hooks/android/before-plugin-install.js index eb86812..e720d6d 100644 --- a/install/hooks/android/before-plugin-install.js +++ b/install/hooks/android/before-plugin-install.js @@ -38,22 +38,19 @@ function unzipAll(callback) { } module.exports = function(context) { - var Q = context.requireCordovaModule('q'); - var deferral = new Q.defer(); - // Create the node project folder if it doesn't exist if (!fs.existsSync(nodeProjectFolder)) { fs.mkdirSync(nodeProjectFolder); } - // Unzip the libnode.so files for each architecture - unzipAll(function(err) { - if (err) { - deferral.reject(err); - } else { - deferral.resolve(); - } + return new Promise((resolve, reject) => { + // Unzip the libnode.so files for each architecture + unzipAll(function(err) { + if (err) { + reject(err); + } else { + resolve(); + } + }); }); - - return deferral.promise; } diff --git a/install/hooks/ios/after-plugin-install.js b/install/hooks/ios/after-plugin-install.js index e1dc749..392c1ca 100644 --- a/install/hooks/ios/after-plugin-install.js +++ b/install/hooks/ios/after-plugin-install.js @@ -2,7 +2,7 @@ var path = require('path'); var fs = require('fs'); module.exports = function(context) { - var xcode = context.requireCordovaModule('xcode'); + var xcode = require('xcode'); // Require the iOS platform Api to get the Xcode .pbxproj path. var iosPlatformPath = path.join(context.opts.projectRoot, 'platforms', 'ios'); diff --git a/install/hooks/ios/before-plugin-install.js b/install/hooks/ios/before-plugin-install.js index a7aea2e..b72114e 100644 --- a/install/hooks/ios/before-plugin-install.js +++ b/install/hooks/ios/before-plugin-install.js @@ -9,29 +9,26 @@ const zipFileName = nodeMobileFileName + '.tar.zip'; const zipFilePath = nodeMobileFolderPath + zipFileName module.exports = function(context) { - var Q = context.requireCordovaModule('q'); - var deferral = new Q.defer(); - // Create the node project folder if it doesn't exist if (!fs.existsSync(nodeProjectFolder)) { fs.mkdirSync(nodeProjectFolder); } - // Unzip and untar the libnode.Framework - if (fs.existsSync(zipFilePath)) { - targz2().extract(zipFilePath, nodeMobileFolderPath, function(err) { - if (err) { - deferral.reject(err); - } else { - fs.unlinkSync(zipFilePath); - deferral.resolve(); - } - }); - } else if (!fs.existsSync(nodeMobileFilePath)) { - deferral.reject(new Error(nodeMobileFileName + ' is missing')); - } else { - deferral.resolve(); - } - - return deferral.promise; + return new Promise((resolve, reject) => { + // Unzip and untar the libnode.Framework + if (fs.existsSync(zipFilePath)) { + targz2().extract(zipFilePath, nodeMobileFolderPath, function(err) { + if (err) { + reject(err); + } else { + fs.unlinkSync(zipFilePath); + resolve(); + } + }); + } else if (!fs.existsSync(nodeMobileFilePath)) { + reject(new Error(nodeMobileFileName + ' is missing')); + } else { + resolve(); + } + }); } diff --git a/install/hooks/ios/before-plugin-uninstall.js b/install/hooks/ios/before-plugin-uninstall.js index c369a88..3b1d3f5 100644 --- a/install/hooks/ios/before-plugin-uninstall.js +++ b/install/hooks/ios/before-plugin-uninstall.js @@ -2,7 +2,7 @@ var path = require('path'); var fs = require('fs'); module.exports = function(context) { - var xcode = context.requireCordovaModule('xcode'); + var xcode = require('xcode'); // Adds a custom function to remove script build phases, which is not supported on cordova's Xcode module yet. xcode.project.prototype.myRemovePbxScriptBuildPhase = function (buildPhaseName, target) { diff --git a/package.json b/package.json index 712fe8a..9097edf 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "license": "MIT", "dependencies": { "nodejs-mobile-gyp": "^0.3.1", - "tar.gz2": "^1.0.0" + "tar.gz2": "^1.0.0", + "xcode": "^2.0.0" }, "homepage": "https://code.janeasystems.com/nodejs-mobile", "repository": { diff --git a/tests/hooks/both/install-nodejs-test-project.js b/tests/hooks/both/install-nodejs-test-project.js index e80eeff..ec3585c 100644 --- a/tests/hooks/both/install-nodejs-test-project.js +++ b/tests/hooks/both/install-nodejs-test-project.js @@ -3,15 +3,12 @@ const path = require('path'); module.exports = function(context) { - var Q = context.requireCordovaModule('q'); - var deferral = new Q.defer(); - var projectRoot = context.opts.projectRoot; var pluginRoot = context.opts.plugin.dir; - fse.copy(path.join(pluginRoot,'nodejs-project'),path.join(projectRoot,'www','nodejs-project')) - .then( () => deferral.resolve() ) - .catch ( err => deferral.reject(err) ); - - return deferral.promise; + return new Promise((resolve, reject) => { + fse.copy(path.join(pluginRoot,'nodejs-project'),path.join(projectRoot,'www','nodejs-project')) + .then( () => resolve() ) + .catch ( err => reject(err) ); + }); }