Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bem-config

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bem-config - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

41

index.js

@@ -29,6 +29,5 @@ 'use strict';

* @param {Boolean} isSync - flag to resolve configs synchronously
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Promise|Array}
*/
BemConfig.prototype.configs = function(isSync, customLevelsConfig) {
BemConfig.prototype.configs = function(isSync) {
var options = this._options,

@@ -41,3 +40,4 @@ cwd = options.cwd,

fsHome: options.fsHome,
name: options.name || 'bem'
name: options.name || 'bem',
extendBy: options.extendBy
};

@@ -52,2 +52,3 @@

if (isSync) {
var configs = this._configs || (this._configs = rc.sync(rcOpts));

@@ -59,3 +60,3 @@

return configs.map(function(config) {
return plugin(config, configs, customLevelsConfig, options);
return plugin(config, configs, options);
});

@@ -77,3 +78,3 @@ }, configs);

return new Promise(function(resolve) {
plugin(config, configs, customLevelsConfig, options, resolve);
plugin(config, configs, options, resolve);
});

@@ -104,7 +105,6 @@ }));

* Returns merged config
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Promise}
*/
BemConfig.prototype.get = function(customLevelsConfig) {
return this.configs(false, customLevelsConfig).then(function(configs) {
BemConfig.prototype.get = function() {
return this.configs().then(function(configs) {
return merge(configs);

@@ -117,9 +117,8 @@ });

* @param {String} pathToLevel - level path
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Promise}
*/
BemConfig.prototype.level = function(pathToLevel, customLevelsConfig) {
BemConfig.prototype.level = function(pathToLevel) {
var _this = this;
return this.configs(false, customLevelsConfig)
return this.configs()
.then(function(configs) {

@@ -155,9 +154,8 @@ return getLevelByConfigs(

* Returns map of settings for each of level
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Promise}
*/
BemConfig.prototype.levelMap = function(customLevelsConfig) {
BemConfig.prototype.levelMap = function() {
var _this = this;
return this.get(customLevelsConfig).then(function(config) {
return this.get().then(function(config) {
var projectLevels = config.levels,

@@ -208,7 +206,6 @@ libNames = config.libs ? Object.keys(config.libs) : [];

* Returns merged config synchronously
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Object}
*/
BemConfig.prototype.getSync = function(customLevelsConfig) {
return merge(this.configs(true, customLevelsConfig));
BemConfig.prototype.getSync = function() {
return merge(this.configs(true));
}

@@ -219,6 +216,5 @@

* @param {String} pathToLevel - level path
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Object}
*/
BemConfig.prototype.levelSync = function(pathToLevel, customLevelsConfig) {
BemConfig.prototype.levelSync = function(pathToLevel) {
// TODO: cache

@@ -228,3 +224,3 @@ return getLevelByConfigs(

this._options,
this.configs(true, customLevelsConfig),
this.configs(true),
this._root);

@@ -253,7 +249,6 @@ };

* Returns map of settings for each of level synchronously
* @param {Object} [customLevelsConfig] - additional config for levels
* @returns {Object}
*/
BemConfig.prototype.levelMapSync = function(customLevelsConfig) {
var config = this.getSync(customLevelsConfig),
BemConfig.prototype.levelMapSync = function() {
var config = this.getSync(),
projectLevels = config.levels,

@@ -260,0 +255,0 @@ libNames = config.libs ? Object.keys(config.libs) : [];

{
"name": "bem-config",
"version": "3.2.0",
"version": "3.2.1",
"description": "Config module for bem-tools",

@@ -35,3 +35,3 @@ "main": "index.js",

"dependencies": {
"betterc": "^1.0.0",
"betterc": "^1.3.0",
"es6-object-assign": "^1.0.2",

@@ -38,0 +38,0 @@ "glob": "^7.0.5",

@@ -9,7 +9,7 @@ 'use strict';

module.exports = function(config, configs, customLevelsConfig, options, cb) {
module.exports = function(config, configs, options, cb) {
var cwd = options.cwd || process.cwd(),
source = config.__source,
res = _.cloneDeep(config),
levels = merge(res.levels, customLevelsConfig),
levels = res.levels || {},
levelsKeys = Object.keys(levels);

@@ -16,0 +16,0 @@

@@ -409,5 +409,6 @@ 'use strict';

test('should merge levels configs with customLevelsConfig', async t => {
const bemConfig = config([
{
test('should respect extendedBy from rc options', async t => {
const pathToConfig = path.resolve(__dirname, 'mocks', 'argv-conf.json');
const actual = await notStubbedBemConfig({
defaults: {
levels: {

@@ -418,9 +419,27 @@ 'path/to/level': {

}
}
}
]);
},
common: 'initial',
original: 'blah'
},
extendBy: {
levels: { 'path/to/level': { test2: 2, same: 'new' } },
common: 'overriden',
extended: 'yo'
},
pathToConfig: pathToConfig,
fsRoot: process.cwd(),
fsHome: process.cwd()
}).level('path/to/level');
const actual = await bemConfig().level('path/to/level', { 'path/to/level': { test2: 2, same: 'new' } });
const expected = {
test1: 1,
test2: 2,
same: 'new',
common: 'overriden',
original: 'blah',
extended: 'yo',
argv: true
};
t.deepEqual(actual, { test1: 1, test2: 2, same: 'new' });
t.deepEqual(actual, expected);
});

@@ -326,33 +326,36 @@ 'use strict';

test('should merge levels configs', t => {
const bemConfig = config([
{
test('should respect extendedBy from rc options', t => {
const pathToConfig = path.resolve(__dirname, 'mocks', 'argv-conf.json');
const actual = notStubbedBemConfig({
defaults: {
levels: {
'path/to/level': {
test1: 1
}
}
}
]);
t.deepEqual(
bemConfig().levelSync('path/to/level', { 'path/to/level': { test2: 2 } }),
{ test1: 1, test2: 2 });
});
test('should merge levels configs with customLevelsConfig', t => {
const bemConfig = config([
{
levels: {
'path/to/level': {
test1: 1,
same: 'initial'
}
}
}
]);
},
common: 'initial',
original: 'blah'
},
extendBy: {
levels: { 'path/to/level': { test2: 2, same: 'new' } },
common: 'overriden',
extended: 'yo'
},
pathToConfig: pathToConfig,
fsRoot: process.cwd(),
fsHome: process.cwd()
}).levelSync('path/to/level');
const actual = bemConfig().levelSync('path/to/level', { 'path/to/level': { test2: 2, same: 'new' } });
const expected = {
test1: 1,
test2: 2,
same: 'new',
common: 'overriden',
original: 'blah',
extended: 'yo',
argv: true
};
t.deepEqual(actual, { test1: 1, test2: 2, same: 'new' });
t.deepEqual(actual, expected);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc