Comparing version 0.0.1 to 0.0.2
@@ -30,7 +30,7 @@ /* jshint node:true */ | ||
*/ | ||
exports.ENV_VARIABLE_NAME = 'STAGE'; | ||
exports.STAGE_ENV_VARIABLE_NAME = 'STAGE'; | ||
/** | ||
* Returns true or false depending on the environment stage name: | ||
* if process.env.<ENV_VARIABLE_NAME> equals 'LAB' or 'LOCAL', | ||
* if process.env.<STAGE_ENV_VARIABLE_NAME> equals 'LAB' or 'LOCAL', | ||
* devmode will be active | ||
@@ -41,3 +41,3 @@ * | ||
exports.isActive = function isActive () { | ||
var stageName = process.env[exports.ENV_VARIABLE_NAME]; | ||
var stageName = process.env[exports.STAGE_ENV_VARIABLE_NAME]; | ||
@@ -106,1 +106,10 @@ // if stage name is listed, return true | ||
}; | ||
// output whether or not devmode is active | ||
if (exports.isActive()) { | ||
console.info( | ||
'\n ############################\n' + | ||
' DEVMODE ACTIVE\n' + | ||
' ############################\n' | ||
); | ||
} |
{ | ||
"name": "devmode", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./lib/devmode", |
@@ -11,3 +11,53 @@ # devmode | ||
Uses environment variables to enable or disable development mode functionality in your package. | ||
## Installation | ||
npm install devmode --save | ||
## Usage | ||
### Load Package | ||
var devmode = require('devmode'); | ||
### Stage Environment Variable Name | ||
// set a custom variable name. default is 'STAGE' | ||
devmode.STAGE_ENV_VARIABLE_NAME = <YOUR_STAGE_ENV_VARIABLE_NAME>; | ||
### Method "isActive" | ||
if (devmode.isActive()) { | ||
// code will run only in dev mode, which means | ||
// process.env.<YOUR_STAGE_ENV_VARIABLE_NAME> equals 'LAB' or 'LOCAL' | ||
} | ||
### Method "require" | ||
var dependency = devmode.require('dependency'); | ||
Depending on the dev mode status, the dependency package will be loaded | ||
from the `node_modules` (disabled) or from the `workplace directory` (enabled) | ||
where your packages are maintained. | ||
It is very useful if your package relays on modules that you also | ||
have maintain or to extend. In devmode the modules are loaded from | ||
the `workplace directory` and you can edit, test and commit them directly. | ||
<pre> | ||
<WORKPLACE> | ||
|_ package | ||
| | | ||
| |_ node_modules | ||
| | | ||
| |_ devmode | ||
| |_ package.module.1 (loaded on devmode disabled) | ||
| |_ package.module.2 (loaded on devmode disabled) | ||
| | ||
|_ package.module.1 (loaded on devmode enabled) | ||
|_ package.module.2 (loaded on devmode enabled) | ||
</pre> | ||
-------------- | ||
@@ -14,0 +64,0 @@ Copyright (c) 2015 Luscus (luscus.redbeard@gmail.com) |
@@ -20,6 +20,6 @@ /* jshint node:true */ | ||
it('should have a property "ENV_VARIABLE_NAME"', function () { | ||
devmode.should.have.property('ENV_VARIABLE_NAME'); | ||
devmode.ENV_VARIABLE_NAME.should.be.an('string'); | ||
devmode.ENV_VARIABLE_NAME.should.equal('STAGE'); | ||
it('should have a property "STAGE_ENV_VARIABLE_NAME"', function () { | ||
devmode.should.have.property('STAGE_ENV_VARIABLE_NAME'); | ||
devmode.STAGE_ENV_VARIABLE_NAME.should.be.an('string'); | ||
devmode.STAGE_ENV_VARIABLE_NAME.should.equal('STAGE'); | ||
}); | ||
@@ -45,3 +45,3 @@ | ||
// runs after all tests in this block | ||
process.env[devmode.ENV_VARIABLE_NAME] = 'LOCAL'; | ||
process.env[devmode.STAGE_ENV_VARIABLE_NAME] = 'LOCAL'; | ||
}); | ||
@@ -63,3 +63,3 @@ | ||
it('should return "' + test.status + '" for process.env.STAGE="' + test.value + '"', function () { | ||
process.env[devmode.ENV_VARIABLE_NAME] = test.value; | ||
process.env[devmode.STAGE_ENV_VARIABLE_NAME] = test.value; | ||
var status = devmode.isActive(); | ||
@@ -74,3 +74,3 @@ | ||
describe('active - getRequirePath method', function () { | ||
process.env[devmode.ENV_VARIABLE_NAME] = 'LOCAL'; | ||
process.env[devmode.STAGE_ENV_VARIABLE_NAME] = 'LOCAL'; | ||
@@ -110,3 +110,3 @@ var requirePaths = [ | ||
it('should return "' + test.path + '" as ' + (test.changed ? 'absolute' : 'relative') + ' path', function () { | ||
process.env[devmode.ENV_VARIABLE_NAME] = 'TEST'; | ||
process.env[devmode.STAGE_ENV_VARIABLE_NAME] = 'TEST'; | ||
var path = devmode.getRequirePath(test.path); | ||
@@ -113,0 +113,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11683
216
70