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

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


The following commit(s) were added to refs/heads/master by this push:
     new 457bfa0  refactor: do not infer project root from script location 
(#1202)
457bfa0 is described below

commit 457bfa014fe51ff8da99676c313d9f0b7a69801d
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Mon Nov 22 10:13:34 2021 +0900

    refactor: do not infer project root from script location (#1202)
    
    Co-authored-by: Raphael von der Grün <raphine...@gmail.com>
---
 bin/templates/scripts/cordova/Api.js       |  2 +-
 bin/templates/scripts/cordova/lib/build.js |  6 +++---
 bin/templates/scripts/cordova/lib/clean.js |  5 ++---
 bin/templates/scripts/cordova/lib/run.js   | 10 +++++-----
 tests/spec/create.spec.js                  |  2 +-
 5 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/bin/templates/scripts/cordova/Api.js 
b/bin/templates/scripts/cordova/Api.js
index 1b5d33e..180346f 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -73,7 +73,7 @@ class Api {
     constructor (platform, platformRootDir, events) {
         // 'platform' property is required as per PlatformApi spec
         this.platform = platform || 'ios';
-        this.root = platformRootDir || path.resolve(__dirname, '..');
+        this.root = platformRootDir;
 
         setupEvents(events);
 
diff --git a/bin/templates/scripts/cordova/lib/build.js 
b/bin/templates/scripts/cordova/lib/build.js
index 0dedbeb..0e00aa9 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -85,9 +85,9 @@ function getDefaultSimulatorTarget () {
 }
 
 /** @returns {Promise<void>} */
-module.exports.run = buildOpts => {
+module.exports.run = function (buildOpts) {
+    const projectPath = this.root;
     let emulatorTarget = '';
-    const projectPath = path.join(__dirname, '..', '..');
     let projectName = '';
 
     buildOpts = buildOpts || {};
@@ -192,7 +192,7 @@ module.exports.run = buildOpts => {
                 writeCodeSignStyle('Automatic');
             }
 
-            return fs.writeFile(path.join(__dirname, '..', 
'build-extras.xcconfig'), extraConfig, 'utf-8');
+            return fs.writeFile(path.join(projectPath, 
'cordova/build-extras.xcconfig'), extraConfig, 'utf-8');
         }).then(() => {
             const configuration = buildOpts.release ? 'Release' : 'Debug';
 
diff --git a/bin/templates/scripts/cordova/lib/clean.js 
b/bin/templates/scripts/cordova/lib/clean.js
index 821c7ea..3874855 100644
--- a/bin/templates/scripts/cordova/lib/clean.js
+++ b/bin/templates/scripts/cordova/lib/clean.js
@@ -22,9 +22,8 @@ const fs = require('fs-extra');
 const execa = require('execa');
 const { CordovaError } = require('cordova-common');
 
-const projectPath = path.join(__dirname, '..', '..');
-
-module.exports.run = () => {
+module.exports.run = function () {
+    const projectPath = this.root;
     const projectName = fs.readdirSync(projectPath).filter(name => 
path.extname(name) === '.xcodeproj');
 
     if (!projectName) {
diff --git a/bin/templates/scripts/cordova/lib/run.js 
b/bin/templates/scripts/cordova/lib/run.js
index 6ae7427..678bd13 100644
--- a/bin/templates/scripts/cordova/lib/run.js
+++ b/bin/templates/scripts/cordova/lib/run.js
@@ -24,11 +24,10 @@ const { CordovaError, events } = require('cordova-common');
 const check_reqs = require('./check_reqs');
 const fs = require('fs-extra');
 
-const cordovaPath = path.join(__dirname, '..');
-const projectPath = path.join(__dirname, '..', '..');
-
 /** @returns {Promise<void>} */
-module.exports.run = runOptions => {
+module.exports.run = function (runOptions) {
+    const projectPath = this.root;
+
     // Validate args
     if (runOptions.device && runOptions.emulator) {
         return Promise.reject(new CordovaError('Only one of 
"device"/"emulator" options should be specified'));
@@ -185,7 +184,8 @@ async function deployToSim (appPath, target) {
 }
 
 function startSim (appPath, target) {
-    const logPath = path.join(cordovaPath, 'console.log');
+    const projectPath = path.join(path.dirname(appPath), '../..');
+    const logPath = path.join(projectPath, 'cordova/console.log');
     const deviceTypeId = `com.apple.CoreSimulator.SimDeviceType.${target}`;
 
     const subprocess = execa(
diff --git a/tests/spec/create.spec.js b/tests/spec/create.spec.js
index c8da4ac..63a0815 100644
--- a/tests/spec/create.spec.js
+++ b/tests/spec/create.spec.js
@@ -66,7 +66,7 @@ function verifyProjectBundleIdentifier (tmpDir, projectName, 
expectedBundleIdent
 function verifyBuild (tmpDir) {
     const Api = require(path.join(tmpDir, 'cordova/Api.js'));
 
-    return expectAsync(new Api().build({ emulator: true }))
+    return expectAsync(new Api('ios', tmpDir).build({ emulator: true }))
         .toBeResolved();
 }
 

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

Reply via email to