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

creature-features

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

creature-features - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

5

features/default.json

@@ -5,5 +5,4 @@ {

"DefaultOverride": false,
"IsDevelopment": false,
"IsTest": false,
"DefaultLocation": true
"DefaultLocation": true,
"IsThisTheDefaultFile": true
}

2

features/development.json

@@ -6,3 +6,3 @@ {

"IsDevelopment": true,
"IsTest": false
"IsTest": false,
}

@@ -5,4 +5,3 @@ {

"DefaultOverride": true,
"IsDevelopment": false,
"IsTest": true
}

@@ -8,3 +8,3 @@ 'use strict';

var endWith = require('end-with');
var exists = require('file-exists');
module.exports = function (config) {

@@ -35,3 +35,8 @@ var env = void 0,

var featuresFiles = [baseFeatures, featuresFile];
var featuresFiles = [];
featuresFiles.push(baseFeatures);
if (typeof featuresFile === 'string' && exists.sync(featuresFile)) {
featuresFiles.push(featuresFile);
}
if (env === 'development') {

@@ -50,4 +55,3 @@ // look for a "named" development file

});
return Object.assign.apply(Object, _toConsumableArray(requiredFeatures));
};
{
"name": "creature-features",
"version": "2.0.2",
"version": "2.1.0",
"description": "Feature flags for node.js",

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

"pretest": "npm run build",
"test": "cross-env NODE_ENV=test ava test/*.js",
"test": "ava test/*.js",
"cov": "cross-env NODE_ENV=test nyc ava test/*.js"

@@ -42,4 +42,5 @@ },

"dependencies": {
"end-with": "^1.0.2"
"end-with": "^1.0.2",
"file-exists": "^3.0.1"
}
}
const path = require('path');
const fs = require('fs');
const endWith = require('end-with');
const exists = require('file-exists');
module.exports = function (config) {

@@ -25,3 +25,8 @@ let env, featuresFile, baseFeatures, overrides, locationBase = './features/';

const featuresFiles = [baseFeatures, featuresFile];
const featuresFiles = [];
featuresFiles.push(baseFeatures);
if (typeof featuresFile === 'string' && exists.sync(featuresFile)) {
featuresFiles.push(featuresFile);
}
if (env === 'development') {

@@ -38,4 +43,3 @@ // look for a "named" development file

const requiredFeatures = featuresFiles.map((file) => require(file));
return Object.assign(...requiredFeatures);
}

@@ -1,19 +0,25 @@

const creature = require('../index');
const features = creature();
const test = require('ava');
test('Load features from default location', (t) => {
process.env.NODE_ENV = null;
const creature = require('../index');
const features = creature();
t.plan(3);
t.true(features.FirstFeature);
t.true(features.DefaultOverride);
t.true(features.IsTest);
t.true(!features.DefaultOverride);
t.true(!features.IsTest);
process.env.NODE_ENV = null;
});
test('Load named development features', (t) => {
process.env.NODE_ENV = 'development';
const creature = require('../index');
const namedFeatures = creature('development');
t.plan(1);
t.true(namedFeatures.IsNamed);
process.env.NODE_ENV = null;
});
test('Load features with a custom env', (t) => {
process.env.NODE_ENV = 'test';
const creature = require('../index');
const envFeatures = creature('development')

@@ -24,5 +30,17 @@ t.plan(3);

t.true(envFeatures.IsTest === false);
process.env.NODE_ENV = null;
});
test('Load features with a custom env that does not have a feature file', (t) => {
process.env.NODE_ENV = 'stable';
const creature = require('../index');
const envFeatures = creature()
t.plan(2);
t.true(envFeatures.FirstFeature);
t.true(envFeatures.DefaultOverride === false);
process.env.NODE_ENV = null;
});
test('Load features from a custom location', (t) => {
process.env.NODE_ENV = 'development';
const creature = require('../index');
const locationFeatures = creature({

@@ -35,5 +53,8 @@ location: './test/features/'

t.true(locationFeatures.DefaultLocation === undefined);
process.env.NODE_ENV = null;
});
test('Load features from a custom location and a custom environment', (t) => {
process.env.NODE_ENV = 'test';
const creature = require('../index');
const locationFeatures = creature({

@@ -46,4 +67,7 @@ location: './test/features/',

t.true(locationFeatures.DevelopmentFeature);
process.env.NODE_ENV = null;
});
test('Load features from a custom location without trailing slash', (t) => {
process.env.NODE_ENV = 'development';
const creature = require('../index');
const locationFeatures = creature({

@@ -56,2 +80,3 @@ location: './test/features'

t.true(locationFeatures.DefaultLocation === undefined);
process.env.NODE_ENV = null;
});
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