rajt 0.0.54 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/dev.ts +3 -0
- package/src/utils/environment.ts +21 -7
package/package.json
CHANGED
package/src/dev.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { registerHandler, registerMiddleware } from './register'
|
|
|
6
6
|
import { Ability } from './auth'
|
|
7
7
|
import { getAvailablePort } from './utils/port'
|
|
8
8
|
import jsonImport from './utils/json-import'
|
|
9
|
+
import { setEnv, detectEnvironment } from './utils/environment'
|
|
10
|
+
|
|
11
|
+
setEnv(detectEnvironment())
|
|
9
12
|
|
|
10
13
|
config({ path: '../../.env.dev' })
|
|
11
14
|
|
package/src/utils/environment.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
const prd = Symbol('prd')
|
|
2
|
+
const dev = Symbol('dev')
|
|
3
|
+
|
|
4
|
+
let env = prd
|
|
5
|
+
|
|
6
|
+
export const getEnv = () => env
|
|
7
|
+
export const setEnv = (e: symbol) => env = e
|
|
8
|
+
|
|
9
|
+
export function detectEnvironment() {
|
|
2
10
|
try {
|
|
3
11
|
if (
|
|
4
|
-
process.env?.npm_lifecycle_event
|
|
12
|
+
process.env?.npm_lifecycle_event == 'dev'
|
|
5
13
|
|| process.env?.AWS_SAM_LOCAL
|
|
6
|
-
|| process?.argv?.includes('--dev')
|
|
14
|
+
// || process?.argv?.includes('--dev')
|
|
15
|
+
|| process?.argv?.some(arg => ['--dev', '--development', '--watch'].includes(arg))
|
|
7
16
|
|| process?.execArgv?.includes('--watch')
|
|
8
17
|
|| import.meta.url?.includes('localhost')
|
|
9
18
|
) {
|
|
10
|
-
return
|
|
19
|
+
return dev
|
|
11
20
|
}
|
|
12
21
|
} catch (e) { }
|
|
13
22
|
|
|
14
|
-
return
|
|
23
|
+
return prd
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
export const
|
|
18
|
-
|
|
26
|
+
export const isEnv = (e: symbol) => env == e
|
|
27
|
+
|
|
28
|
+
export const isDev = () => env == dev
|
|
29
|
+
export const isProd = () => env == prd
|
|
30
|
+
|
|
31
|
+
export const isDevelopment = isDev
|
|
32
|
+
export const isProduction = isProd
|
|
19
33
|
export const isPrd = isProd
|