fancy-test
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -0,1 +1,9 @@ | ||
<a name="0.6.4"></a> | ||
## [0.6.4](https://github.com/jdxcode/fancy-test/compare/33db7edbb2cf97b178c4490bbff6740abcd28840...v0.6.4) (2018-01-28) | ||
### Bug Fixes | ||
* close over envs ([16de1b4](https://github.com/jdxcode/fancy-test/commit/16de1b4)) | ||
<a name="0.6.3"></a> | ||
@@ -2,0 +10,0 @@ ## [0.6.3](https://github.com/jdxcode/fancy-test/compare/460043efd4a967ac07a5efadcc421211627c9e6c...v0.6.3) (2018-01-28) |
@@ -1,5 +0,8 @@ | ||
import { Env, EnvOptions } from './types'; | ||
import { EnvOptions } from './types'; | ||
declare const _default: (env: { | ||
[k: string]: string | null | undefined; | ||
}, opts?: EnvOptions) => Env; | ||
}, opts?: EnvOptions) => { | ||
run(): void; | ||
finally(): void; | ||
}; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _ = require("lodash"); | ||
exports.default = (env, opts = {}) => ({ | ||
run(ctx) { | ||
// normalize to undefined | ||
const normalizedEnv = _.mapValues(env, v => v === null ? undefined : v); | ||
// store previous env for finally | ||
ctx.envs = ctx.envs || []; | ||
ctx.envs.push(process.env); | ||
if (opts.clear) { | ||
process.env = Object.assign({}, normalizedEnv); | ||
} | ||
else { | ||
process.env = Object.assign({}, process.env, normalizedEnv); | ||
Object.entries(normalizedEnv) | ||
.filter(([, v]) => v === undefined) | ||
.forEach(([k]) => { delete process.env[k]; }); | ||
} | ||
}, | ||
finally(ctx) { | ||
const env = ctx.envs.pop(); | ||
if (env) | ||
process.env = env; | ||
}, | ||
}); | ||
exports.default = (env, opts = {}) => { | ||
const envs = []; | ||
return { | ||
run() { | ||
// normalize to undefined | ||
const normalizedEnv = _.mapValues(env, v => v === null ? undefined : v); | ||
// store previous env for finally | ||
envs.push(process.env); | ||
if (opts.clear) { | ||
process.env = Object.assign({}, normalizedEnv); | ||
} | ||
else { | ||
process.env = Object.assign({}, process.env, normalizedEnv); | ||
Object.entries(normalizedEnv) | ||
.filter(([, v]) => v === undefined) | ||
.forEach(([k]) => { delete process.env[k]; }); | ||
} | ||
}, | ||
finally() { | ||
const env = envs.pop(); | ||
if (env) | ||
process.env = env; | ||
}, | ||
}; | ||
}; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="nock" /> | ||
@@ -44,5 +43,3 @@ import { expect } from './chai'; | ||
env: { | ||
output: { | ||
envs: NodeJS.ProcessEnv[]; | ||
}; | ||
output: {}; | ||
a1: { | ||
@@ -49,0 +46,0 @@ [k: string]: string | null | undefined; |
@@ -60,6 +60,2 @@ /// <reference types="mocha" /> | ||
} | ||
export interface Env extends Plugin<{ | ||
envs: (typeof process.env)[]; | ||
}> { | ||
} | ||
export declare type MochaDone = (error?: any) => any; |
{ | ||
"name": "fancy-test", | ||
"description": "extendable utilities for testing", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/jdxcode/fancy-test/issues", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34518
0
516