Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not explicitly require modules from project directory #713

Merged
merged 2 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions bin/templates/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions bin/templates/cordova/lib/builders/builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down