File tree Expand file tree Collapse file tree 3 files changed +24
-23
lines changed
Expand file tree Collapse file tree 3 files changed +24
-23
lines changed Original file line number Diff line number Diff line change 11import * as path from 'path' ;
22import * as dotenv from 'dotenv' ;
33import * as pkg from '../package.json' ;
4+ import { toBool , toNumber , normalizePort , getOsEnv } from './lib/env' ;
45
56/**
67 * Load .env file or for tests the .env.test file.
@@ -72,26 +73,3 @@ export const env = {
7273 password : getOsEnv ( 'MONITOR_PASSWORD' ) ,
7374 } ,
7475} ;
75-
76- function getOsEnv ( key : string ) : string {
77- return process . env [ key ] as string ;
78- }
79-
80- function toNumber ( value : string ) : number {
81- return parseInt ( value , 10 ) ;
82- }
83-
84- function toBool ( value : string ) : boolean {
85- return value === 'true' ;
86- }
87-
88- function normalizePort ( port : string ) : number | string | boolean {
89- const parsedPort = parseInt ( port , 10 ) ;
90- if ( isNaN ( parsedPort ) ) { // named pipe
91- return port ;
92- }
93- if ( parsedPort >= 0 ) { // port number
94- return parsedPort ;
95- }
96- return false ;
97- }
Original file line number Diff line number Diff line change 1+ export * from './utils' ;
Original file line number Diff line number Diff line change 1+ export function getOsEnv ( key : string ) : string {
2+ return process . env [ key ] as string ;
3+ }
4+
5+ export function toNumber ( value : string ) : number {
6+ return parseInt ( value , 10 ) ;
7+ }
8+
9+ export function toBool ( value : string ) : boolean {
10+ return value === 'true' ;
11+ }
12+
13+ export function normalizePort ( port : string ) : number | string | boolean {
14+ const parsedPort = parseInt ( port , 10 ) ;
15+ if ( isNaN ( parsedPort ) ) { // named pipe
16+ return port ;
17+ }
18+ if ( parsedPort >= 0 ) { // port number
19+ return parsedPort ;
20+ }
21+ return false ;
22+ }
You can’t perform that action at this time.
0 commit comments