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 2018/06/17 13:04:28 UTC
[cordova-create] branch master updated: Drop support for reading
from .cordova/config.json (#18)
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-create.git
The following commit(s) were added to refs/heads/master by this push:
new e953231 Drop support for reading from .cordova/config.json (#18)
e953231 is described below
commit e9532316e55e9e8c8bdf0e9c68076142f9dca938
Author: Raphael von der Grün <ra...@gmail.com>
AuthorDate: Sun Jun 17 15:04:24 2018 +0200
Drop support for reading from .cordova/config.json (#18)
Resolves §2 from apache/cordova-discuss#89
---
index.js | 58 +++++-----------------------------------------------------
package.json | 1 +
2 files changed, 6 insertions(+), 53 deletions(-)
diff --git a/index.js b/index.js
index 61181ca..ec88303 100644
--- a/index.js
+++ b/index.js
@@ -24,6 +24,7 @@ var path = require('path');
var Promise = require('q');
var isUrl = require('is-url');
var shell = require('shelljs');
+var isObject = require('isobject');
var requireFresh = require('import-fresh');
var validateIdentifier = require('valid-identifier');
@@ -75,28 +76,9 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {
throw new CordovaError('Directory not specified. See `cordova help`.');
}
- // read projects .cordova/config.json file for project settings
- var configFile = dotCordovaConfig(dir);
-
- // if data exists in the configFile, lets combine it with cfg
- // cfg values take priority over config file
- if (configFile) {
- var finalConfig = {};
- for (var key1 in configFile) {
- finalConfig[key1] = configFile[key1];
- }
-
- for (var key2 in cfg) {
- finalConfig[key2] = cfg[key2];
- }
-
- cfg = finalConfig;
- }
-
- if (!cfg) {
- throw new CordovaError('Must provide a project configuration.');
- } else if (typeof cfg === 'string') {
- cfg = JSON.parse(cfg);
+ cfg = cfg || {};
+ if (!isObject(cfg)) {
+ throw new CordovaError('If given, cfg must be an object');
}
if (optionalId) cfg.id = optionalId;
@@ -105,20 +87,7 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {
// Make absolute.
dir = path.resolve(dir);
- // dir must be either empty except for .cordova config file or not exist at all..
- var sanedircontents = function (d) {
- var contents = fs.readdirSync(d);
- if (contents.length === 0) {
- return true;
- } else if (contents.length === 1) {
- if (contents[0] === '.cordova') {
- return true;
- }
- }
- return false;
- };
-
- if (fs.existsSync(dir) && !sanedircontents(dir)) {
+ if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
throw new CordovaError('Path already exists and is not empty: ' + dir);
}
@@ -347,23 +316,6 @@ function projectConfig (projectDir) {
}
/**
- * Retrieve and read the .cordova/config file of a cordova project
- *
- * @param {String} project directory
- * @return {JSON data} config file's contents
- */
-function dotCordovaConfig (project_root) {
- var configPath = path.join(project_root, '.cordova', 'config.json');
- var data;
- if (!fs.existsSync(configPath)) {
- data = '{}';
- } else {
- data = fs.readFileSync(configPath, 'utf-8');
- }
- return JSON.parse(data);
-}
-
-/**
* Removes existing files and symlinks them if they exist.
* Symlinks folders: www, merges, hooks
* Symlinks file: config.xml (but only if it exists outside of the www folder)
diff --git a/package.json b/package.json
index 9ac95d1..3cacb07 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"cordova-fetch": "^1.3.0",
"import-fresh": "^2.0.0",
"is-url": "^1.2.4",
+ "isobject": "^3.0.1",
"q": "^1.5.1",
"shelljs": "^0.8.2",
"valid-identifier": "0.0.1"
--
To stop receiving notification emails like this one, please contact
raphinesse@apache.org.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org