/*
	Licensed Material - Property of IBM

	(C) Copyright 2015 IBM Corp.

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/


'use strict';

//public
var path = require('path');
var log = require('npmlog');
var propertiesParser = require('properties-parser');
var q = require('q');

/**
 * @param file - glob file which contains the path to wlclient.properties file
*/
function readClientProperties(cwd){
    var d = q.defer();
    //var clientPath = options.path;

    var file = path.join(cwd, 'mfpclient.properties');
    propertiesParser.createEditor(file, function (err, editor) {
            if(err) {
                log.verbose('readClientProperties', 'Failed to read and parse mfpclient.properties: '+err+' '+JSON.stringify(err));
                d.reject();
            } else {
                d.resolve(editor);
            }
    });
    return d.promise;

}

module.exports = readClientProperties;
