You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/04/13 15:35:05 UTC

[cordova-android] branch master updated: Do not explicitly require modules from project directory (#713)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new 4cf3dcf   Do not explicitly require modules from project directory (#713)
4cf3dcf is described below

commit 4cf3dcfaae6dc82ddb1ccf439d209cbcc2f474a0
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Sat Apr 13 17:34:59 2019 +0200

     Do not explicitly require modules from project directory (#713)
    
    * Allow to pass-through projectPath to Builder
    
    * Do not explicitly require modules from project directory
---
 bin/lib/create.js                              | 4 ++--
 bin/templates/cordova/Api.js                   | 6 ++----
 bin/templates/cordova/lib/builders/builders.js | 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/bin/lib/create.js b/bin/lib/create.js
index 3f5bcb1..2fa457f 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -142,8 +142,8 @@ function writeProjectProperties (projectPath, target_api) {
 
 // This makes no sense, what if you're building with a different build system?
 function prepBuildFiles (projectPath) {
-    var buildModule = require(path.resolve(projectPath, 'cordova/lib/builders/builders'));
-    buildModule.getBuilder().prepBuildFiles();
+    var buildModule = require('../templates/cordova/lib/builders/builders');
+    buildModule.getBuilder(projectPath).prepBuildFiles();
 }
 
 function copyBuildRules (projectPath, isLegacy) {
diff --git a/bin/templates/cordova/Api.js b/bin/templates/cordova/Api.js
index cde6e86..30b1fbe 100644
--- a/bin/templates/cordova/Api.js
+++ b/bin/templates/cordova/Api.js
@@ -99,8 +99,7 @@ Api.createPlatform = function (destination, config, options, events) {
     var result;
     try {
         result = require('../../lib/create').create(destination, config, options, events).then(function (destination) {
-            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
-            return new PlatformApi(PLATFORM, destination, events);
+            return new Api(PLATFORM, destination, events);
         });
     } catch (e) {
         events.emit('error', 'createPlatform is not callable from the android project API.');
@@ -130,8 +129,7 @@ Api.updatePlatform = function (destination, options, events) {
     var result;
     try {
         result = require('../../lib/create').update(destination, options, events).then(function (destination) {
-            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
-            return new PlatformApi('android', destination, events);
+            return new Api(PLATFORM, destination, events);
         });
     } catch (e) {
         events.emit('error', 'updatePlatform is not callable from the android project API, you will need to do this manually.');
diff --git a/bin/templates/cordova/lib/builders/builders.js b/bin/templates/cordova/lib/builders/builders.js
index 42fc19d..edc1a52 100644
--- a/bin/templates/cordova/lib/builders/builders.js
+++ b/bin/templates/cordova/lib/builders/builders.js
@@ -24,10 +24,10 @@ const CordovaError = require('cordova-common').CordovaError;
  *
  * @return {Builder} A builder instance for specified build type.
  */
-module.exports.getBuilder = function () {
+module.exports.getBuilder = function (projectPath) {
     try {
         const Builder = require('./ProjectBuilder');
-        return new Builder();
+        return new Builder(projectPath);
     } catch (err) {
         throw new CordovaError('Failed to instantiate ProjectBuilder builder: ' + err);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org