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/11 00:36:48 UTC

[cordova-cli] branch master updated: Fix `cordova config list` command (#421)

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-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 68d700f  Fix `cordova config list` command (#421)
68d700f is described below

commit 68d700f0d71abf57f643df9ddbb68cbbbe6cefd5
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Thu Apr 11 02:36:43 2019 +0200

    Fix `cordova config list` command (#421)
    
    Fixes #418
---
 spec/cli.spec.js | 8 +++-----
 src/cli.js       | 9 +--------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index 7e7b626..abf10e7 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -15,7 +15,6 @@
     under the License.
 */
 
-const fs = require('fs');
 const path = require('path');
 const rewire = require('rewire');
 /*
@@ -438,6 +437,7 @@ describe('cordova cli', () => {
         const cordovaConfig = {};
 
         const confMock = {
+            all: cordovaConfig,
             set (key, value) {
                 cordovaConfig[key] = value;
             },
@@ -503,12 +503,10 @@ describe('cordova cli', () => {
         });
 
         it('Test #047 : config ls is called', () => {
-            spyOn(fs, 'readFile').and.callFake((confPath, cb) => {
-                confHolder = confPath();
-            });
+            const expectedOutput = JSON.stringify(cordovaConfig, null, 4);
 
             return cli(['node', 'cordova', 'config', 'ls']).then(() => {
-                expect(path.basename(confHolder)).toEqual('cordova-config.json');
+                expect(logger.results).toHaveBeenCalledWith(expectedOutput);
             });
         });
 
diff --git a/src/cli.js b/src/cli.js
index 8e07df7..0d5089d 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -29,7 +29,6 @@ var logger = require('cordova-common').CordovaLogger.get();
 var Configstore = require('configstore');
 var conf = new Configstore(pkg.name + '-config');
 var editor = require('editor');
-var fs = require('fs');
 
 var knownOpts = {
     'verbose': Boolean,
@@ -149,13 +148,7 @@ module.exports = function (inputArgs) {
 
     // If "ls" is called
     if (isConfigCmd && (inputArgs[3] === 'ls' || inputArgs[3] === 'list')) {
-        fs.readFile(conf.path, 'utf8', function (err, data) {
-            if (err) {
-                logger.error(err);
-            } else {
-                logger.log(data);
-            }
-        });
+        logger.results(JSON.stringify(conf.all, null, 4));
     }
 
     return Promise.resolve().then(function () {


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