Skip to content

Commit

Permalink
Fix cordova config list command (#421)
Browse files Browse the repository at this point in the history
Fixes #418
  • Loading branch information
raphinesse authored Apr 11, 2019
1 parent 88cc5d9 commit 68d700f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 3 additions & 5 deletions spec/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
under the License.
*/

const fs = require('fs');
const path = require('path');
const rewire = require('rewire');
/*
Expand Down Expand Up @@ -438,6 +437,7 @@ describe('cordova cli', () => {
const cordovaConfig = {};

const confMock = {
all: cordovaConfig,
set (key, value) {
cordovaConfig[key] = value;
},
Expand Down Expand Up @@ -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);
});
});

Expand Down
9 changes: 1 addition & 8 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 68d700f

Please sign in to comment.