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.0.1 to 3.1.0

50

index.js

@@ -56,2 +56,9 @@ 'use strict';

for (var i = 0; i < configs.length; i++) {
if (configs[i].root && configs[i].__source) {
this._root = path.dirname(configs[i].__source);
break;
}
}
plugins.forEach(function(plugin) {

@@ -72,2 +79,9 @@ return configs.map(function(config) {

return rc(rcOpts).then(function(cfgs) {
for (var j = 0; j < cfgs.length; j++) {
if (cfgs[j].root && cfgs[j].__source) {
_this._root = path.dirname(cfgs[j].__source);
break;
}
}
return Promise.all(plugins.map(function(plugin) {

@@ -87,2 +101,17 @@ return new Promise(function(resolve) {

/**
* Returns project root
* @returns {Promise}
*/
BemConfig.prototype.root = function() {
if (this._root) {
return Promise.resolve(this._root);
}
var _this = this;
return this.configs().then(function() {
return _this._root;
});
};
/**
* Returns merged config

@@ -107,3 +136,3 @@ * @returns {Promise}

.then(function(configs) {
return getLevelByConfigs(pathToLevel, _this._options, configs);
return getLevelByConfigs(pathToLevel, _this._options, configs, _this._root);
});

@@ -173,2 +202,15 @@ };

/**
* Returns project root
* @returns {String}
*/
BemConfig.prototype.rootSync = function() {
if (this._root) {
return this._root;
}
this.configs(true);
return this._root;
};
/**
* Returns merged config synchronously

@@ -192,3 +234,3 @@ * @returns {Object}

// TODO: cache
return getLevelByConfigs(pathToLevel, this._options, this.configs(true));
return getLevelByConfigs(pathToLevel, this._options, this.configs(true), this._root);
};

@@ -268,4 +310,4 @@

function getLevelByConfigs(pathToLevel, options, allConfigs) {
var absLevelPath = path.resolve(options.cwd, pathToLevel),
function getLevelByConfigs(pathToLevel, options, allConfigs, root) {
var absLevelPath = path.resolve(root || options.cwd, pathToLevel),
// levelOpts = { __source: absLevelPath };

@@ -272,0 +314,0 @@ levelOpts = {},

2

package.json
{
"name": "bem-config",
"version": "3.0.1",
"version": "3.1.0",
"description": "Config module for bem-tools",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,2 +44,15 @@ 'use strict';

// root()
test('should return project root', async t => {
const bemConfig = config([
{ test: 1, __source: 'some/path' },
{ test: 2, root: true, __source: __filename },
{ other: 'field', __source: 'some/other/path' }
]);
const actual = await bemConfig().root();
t.deepEqual(actual, path.dirname(__filename));
});
// get()

@@ -213,3 +226,3 @@ test('should return merged config', async t => {

},
root: 'true'
root: true
},

@@ -216,0 +229,0 @@ {

@@ -41,2 +41,13 @@ 'use strict';

// root()
test('should return project root', t => {
const bemConfig = config([
{ test: 1, __source: 'some/path' },
{ test: 2, root: true, __source: __filename },
{ other: 'field', __source: 'some/other/path' }
]);
t.deepEqual(bemConfig().rootSync(), path.dirname(__filename));
});
// get()

@@ -43,0 +54,0 @@ test('should return merged config', t => {

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