mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Introduce asenv (#18573)
This commit is contained in:
parent
1e211cd0d4
commit
eddbc9e6f9
26
types/asenv/asenv-tests.ts
Normal file
26
types/asenv/asenv-tests.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { unlessProduction, isDevelopment, isTest, isProduction, getEnv, setEnv } from 'asenv';
|
||||
import { equal, throws } from 'assert';
|
||||
|
||||
// Test isDevelopment()
|
||||
setEnv('development');
|
||||
equal(getEnv(), 'development', 'Should return be true');
|
||||
equal(isDevelopment(), true, 'NODE_ENV should be "development"');
|
||||
equal(isTest(), false, 'NODE_ENV should be "development"');
|
||||
equal(isProduction(), false, 'NODE_ENV should be "development"');
|
||||
equal(unlessProduction(() => true), true, "Shound return true");
|
||||
|
||||
// Test isTest()
|
||||
setEnv('test');
|
||||
equal(getEnv(), 'test', 'Should return be true');
|
||||
equal(isDevelopment(), false, 'NODE_ENV should be "test"');
|
||||
equal(isTest(), true, 'NODE_ENV should be "test"');
|
||||
equal(isProduction(), false, 'NODE_ENV should be "test"');
|
||||
equal(unlessProduction(() => true), true, "Shound return true");
|
||||
|
||||
// Test isProduction()
|
||||
setEnv('production');
|
||||
equal(getEnv(), 'production', 'Should return be true');
|
||||
equal(isDevelopment(), false, 'NODE_ENV should be "production"');
|
||||
equal(isTest(), false, 'NODE_ENV should be "production"');
|
||||
equal(isProduction(), true, 'NODE_ENV should be "production"');
|
||||
equal(unlessProduction(() => true), false, "Shound return false");
|
||||
18
types/asenv/index.d.ts
vendored
Normal file
18
types/asenv/index.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Type definitions for asenv 1.1
|
||||
// Project: https://github.com/a-labo/asenv#readme
|
||||
// Definitions by: Remisery <https://github.com/remisery>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export function getEnv(): string;
|
||||
|
||||
export function isDevelopment(): boolean;
|
||||
|
||||
export function isProduction(): boolean;
|
||||
|
||||
export function isTest(): boolean;
|
||||
|
||||
export function setEnv(env: string): void;
|
||||
|
||||
export function unlessProduction(handle: () => any): any;
|
||||
22
types/asenv/tsconfig.json
Normal file
22
types/asenv/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asenv-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/asenv/tslint.json
Normal file
3
types/asenv/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user