aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/node-utils/src/env.ts
blob: 1a28f509e69b844ae17af1d60bdcd1bfb71ea7de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export function parallelTests () {
  return process.env.MOCHA_PARALLEL === 'true'
}

export function isGithubCI () {
  return !!process.env.GITHUB_WORKSPACE
}

export function areHttpImportTestsDisabled () {
  const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'

  if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')

  return disabled
}

export function areMockObjectStorageTestsDisabled () {
  const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'

  if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')

  return disabled
}

export function areScalewayObjectStorageTestsDisabled () {
  if (areMockObjectStorageTestsDisabled()) return true

  const enabled = process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID && process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY
  if (!enabled) {
    console.log(
      'OBJECT_STORAGE_SCALEWAY_KEY_ID and/or OBJECT_STORAGE_SCALEWAY_ACCESS_KEY are not set, so scaleway object storage tests are disabled'
    )

    return true
  }

  return false
}

export function isTestInstance () {
  return process.env.NODE_ENV === 'test'
}

export function isDevInstance () {
  return process.env.NODE_ENV === 'dev'
}

export function isTestOrDevInstance () {
  return isTestInstance() || isDevInstance()
}

export function isProdInstance () {
  return process.env.NODE_ENV === 'production'
}

export function getAppNumber () {
  return process.env.NODE_APP_INSTANCE || ''
}