Ejemplo n.º 1
0
Archivo: util.js Proyecto: echodis/fecs
exports.getConfig = function (key, filepath, defaults, force) {
    defaults = defaults || {};

    // 未提供起始路径时,使用内置配置
    if (!filepath) {
        return config[key] || defaults;
    }

    var localRcloader = rcloader;
    if (!localRcloader || force) {

        localRcloader = new Manis({
            files: [
                CONFIG_NAME,
                {name: PACKAGE_NAME, get: 'fecs'}
            ]
        });

        localRcloader.setDefault(config);
        if (!rcloader) {
            rcloader = localRcloader;
        }
    }

    return localRcloader.from(filepath)[key] || defaults;
};
Ejemplo n.º 2
0
export function loadConfig(filePath, refresh) {
    if (refresh && STORAGE) {
        return STORAGE;
    }

    let manis = new Manis({
        files: [
            '.lesslintrc'
        ],
        loader(content) {
            if (!content) {
                return '';
            }
            let ret;
            try {
                ret = yaml.load(content);
            }
            catch (e) {}
            return ret;
        }
    });

    manis.setDefault(join(__dirname, './config.yml'));

    STORAGE = manis.from(filePath);

    return STORAGE;
}