@dotenvx/dotenvx 1.75.1 → 2.1.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/README.md +4 -114
  3. package/package.json +8 -7
  4. package/src/cli/actions/decrypt.js +35 -17
  5. package/src/cli/actions/doctor.js +2 -2
  6. package/src/cli/actions/encrypt.js +64 -85
  7. package/src/cli/actions/ext/genexample.js +2 -2
  8. package/src/cli/actions/get.js +22 -7
  9. package/src/cli/actions/keypair.js +55 -42
  10. package/src/cli/actions/login.js +4 -3
  11. package/src/cli/actions/normalizeArmorAliases.js +9 -0
  12. package/src/cli/actions/run.js +65 -22
  13. package/src/cli/actions/set.js +87 -37
  14. package/src/cli/dotenvx.js +8 -23
  15. package/src/lib/api/{postKeypair.js → postArmorKeyring.js} +4 -14
  16. package/src/lib/{helpers/envResolution → conventions}/environment.js +1 -1
  17. package/src/lib/conventions/filepaths.js +9 -0
  18. package/src/lib/conventions/keynames.js +38 -0
  19. package/src/lib/helpers/catchAndLog.js +4 -1
  20. package/src/lib/helpers/cryptography/index.js +2 -9
  21. package/src/lib/helpers/cryptography/{isPublicKey.js → isDotenvPublicKey.js} +2 -2
  22. package/src/lib/helpers/cryptography/isPlainKey.js +7 -0
  23. package/src/lib/helpers/cryptography/mutateKeysSrc.js +5 -21
  24. package/src/lib/helpers/envResolution/index.js +1 -1
  25. package/src/lib/helpers/errors.js +26 -0
  26. package/src/lib/helpers/keypairMetadata.js +1 -1
  27. package/src/lib/helpers/prompts.js +46 -0
  28. package/src/lib/main.d.ts +2 -39
  29. package/src/lib/main.js +83 -46
  30. package/src/lib/providers/armor/index.js +29 -0
  31. package/src/lib/providers/index.js +46 -0
  32. package/src/lib/providers/worker.js +6 -0
  33. package/src/lib/resolvers/envs.js +302 -0
  34. package/src/lib/resolvers/get.js +69 -0
  35. package/src/lib/resolvers/keypair.js +81 -0
  36. package/src/lib/resolvers/ls.js +41 -0
  37. package/src/lib/services/armorDown.js +2 -2
  38. package/src/lib/services/{armorKeypair.js → armorKeyring.js} +14 -51
  39. package/src/lib/services/armorMove.js +2 -2
  40. package/src/lib/services/armorPull.js +2 -2
  41. package/src/lib/services/armorPush.js +2 -2
  42. package/src/lib/services/armorUp.js +2 -2
  43. package/src/lib/services/genexample.js +5 -6
  44. package/src/lib/services/login.js +25 -0
  45. package/src/lib/services/prebuild.js +9 -3
  46. package/src/lib/services/precommit.js +9 -3
  47. package/src/lib/transforms/decrypt.js +83 -0
  48. package/src/lib/transforms/encrypt.js +178 -0
  49. package/src/lib/transforms/set.js +179 -0
  50. package/src/shared/logger.js +5 -0
  51. package/src/cli/actions/normalizeArmorOptions.js +0 -10
  52. package/src/cli/actions/rotate.js +0 -87
  53. package/src/lib/helpers/append.js +0 -62
  54. package/src/lib/helpers/cryptography/armorKeypair.js +0 -42
  55. package/src/lib/helpers/cryptography/armorKeypairSync.js +0 -55
  56. package/src/lib/helpers/cryptography/encryptValue.js +0 -7
  57. package/src/lib/helpers/cryptography/localKeypair.js +0 -14
  58. package/src/lib/helpers/cryptography/mutateKeysSrcSync.js +0 -38
  59. package/src/lib/helpers/cryptography/provision.js +0 -56
  60. package/src/lib/helpers/cryptography/provisionSync.js +0 -51
  61. package/src/lib/helpers/cryptography/provisionWithPrivateKey.js +0 -26
  62. package/src/lib/helpers/escapeDollarSigns.js +0 -5
  63. package/src/lib/helpers/escapeForRegex.js +0 -5
  64. package/src/lib/helpers/evalKeyValue.js +0 -23
  65. package/src/lib/helpers/isIgnoringDotenvKeys.js +0 -19
  66. package/src/lib/helpers/keyResolution/index.js +0 -16
  67. package/src/lib/helpers/keyResolution/keyNamesForEnvFile.js +0 -24
  68. package/src/lib/helpers/keyResolution/keyValues.js +0 -99
  69. package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +0 -85
  70. package/src/lib/helpers/keyResolution/keyValuesSync.js +0 -103
  71. package/src/lib/helpers/keyResolution/readFileKey.js +0 -19
  72. package/src/lib/helpers/keyResolution/readFileKeySync.js +0 -17
  73. package/src/lib/helpers/keyResolution/readProcessKey.js +0 -7
  74. package/src/lib/helpers/localDisplayPath.js +0 -11
  75. package/src/lib/helpers/parse.js +0 -214
  76. package/src/lib/helpers/pluralize.js +0 -10
  77. package/src/lib/helpers/quotes.js +0 -36
  78. package/src/lib/helpers/replace.js +0 -82
  79. package/src/lib/helpers/resolveEscapeSequences.js +0 -5
  80. package/src/lib/services/decrypt.js +0 -156
  81. package/src/lib/services/encrypt.js +0 -213
  82. package/src/lib/services/get.js +0 -76
  83. package/src/lib/services/keypair.js +0 -60
  84. package/src/lib/services/loginPoll.js +0 -36
  85. package/src/lib/services/ls.js +0 -57
  86. package/src/lib/services/rotate.js +0 -197
  87. package/src/lib/services/run.js +0 -255
  88. package/src/lib/services/sets.js +0 -328
@@ -1,156 +0,0 @@
1
- const fsx = require('./../helpers/fsx')
2
- const path = require('path')
3
- const picomatch = require('picomatch')
4
- const { encrypted, scan } = require('@dotenvx/primitives')
5
-
6
- const TYPE_ENV_FILE = 'envFile'
7
-
8
- const Errors = require('./../helpers/errors')
9
-
10
- const {
11
- determine
12
- } = require('./../helpers/envResolution')
13
-
14
- const {
15
- keyNamesForEnvFile,
16
- keyValues
17
- } = require('./../helpers/keyResolution')
18
-
19
- const {
20
- decryptKeyValue
21
- } = require('./../helpers/cryptography')
22
-
23
- const replace = require('./../helpers/replace')
24
- const detectEncoding = require('./../helpers/detectEncoding')
25
-
26
- class Decrypt {
27
- constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false, options = {}) {
28
- this.envs = determine(envs, process.env)
29
- this.key = key
30
- this.excludeKey = excludeKey
31
- this.envKeysFilepath = envKeysFilepath
32
- this.noArmor = noArmor
33
- this.command = options.command
34
-
35
- this.processedEnvs = []
36
- this.changedFilepaths = new Set()
37
- this.unchangedFilepaths = new Set()
38
- }
39
-
40
- async run () {
41
- // example
42
- // envs [
43
- // { type: 'envFile', value: '.env' }
44
- // ]
45
-
46
- this.keys = this._keys()
47
- const excludeKeys = this._excludeKeys()
48
-
49
- this.exclude = picomatch(excludeKeys)
50
- this.include = picomatch(this.keys, { ignore: excludeKeys })
51
-
52
- for (const env of this.envs) {
53
- if (env.type === TYPE_ENV_FILE) {
54
- await this._decryptEnvFile(env.value)
55
- }
56
- }
57
-
58
- return {
59
- processedEnvs: this.processedEnvs,
60
- changedFilepaths: [...this.changedFilepaths],
61
- unchangedFilepaths: [...this.unchangedFilepaths]
62
- }
63
- }
64
-
65
- async _decryptEnvFile (envFilepath) {
66
- const row = {}
67
- row.keys = []
68
- row.type = TYPE_ENV_FILE
69
-
70
- const filepath = path.resolve(envFilepath)
71
- row.filepath = filepath
72
- row.envFilepath = envFilepath
73
-
74
- try {
75
- const encoding = await detectEncoding(filepath)
76
- let envSrc = await fsx.readFileX(filepath, { encoding })
77
- const envParsed = scan(envSrc).parsed
78
-
79
- const { privateKeyName } = keyNamesForEnvFile(envFilepath)
80
- const { privateKeyValue, privateKeySource } = await keyValues(envFilepath, {
81
- keysFilepath: this.envKeysFilepath,
82
- noArmor: this.noArmor,
83
- command: this.command
84
- })
85
-
86
- row.privateKey = privateKeyValue
87
- row.privateKeySource = privateKeySource
88
- row.armoredPrivateKeyUsed = privateKeySource === 'armor'
89
- row.privateKeyName = privateKeyName
90
- row.changed = false // track possible changes
91
-
92
- for (const [key, values] of Object.entries(envParsed)) {
93
- // key excluded - don't decrypt it
94
- if (this.exclude(key)) {
95
- continue
96
- }
97
-
98
- // key effectively excluded (by not being in the list of includes) - don't decrypt it
99
- if (this.keys.length > 0 && !this.include(key)) {
100
- continue
101
- }
102
-
103
- const hasEncrypted = values.some(value => encrypted(value))
104
- if (hasEncrypted) {
105
- row.keys.push(key) // track key(s)
106
-
107
- const decryptedValues = values.map(value => {
108
- if (!encrypted(value)) {
109
- return value
110
- }
111
-
112
- return decryptKeyValue(key, value, privateKeyName, privateKeyValue)
113
- })
114
-
115
- // once newSrc is built write it out
116
- envSrc = replace(envSrc, key, decryptedValues)
117
-
118
- row.changed = true // track change
119
- }
120
- }
121
-
122
- row.envSrc = envSrc
123
- if (row.changed) {
124
- this.changedFilepaths.add(envFilepath)
125
- } else {
126
- this.unchangedFilepaths.add(envFilepath)
127
- }
128
- } catch (e) {
129
- if (e.code === 'ENOENT') {
130
- row.error = new Errors({ envFilepath, filepath }).missingEnvFile()
131
- } else {
132
- row.error = e
133
- }
134
- }
135
-
136
- this.processedEnvs.push(row)
137
- }
138
-
139
- _keys () {
140
- if (!Array.isArray(this.key)) {
141
- return [this.key]
142
- }
143
-
144
- return this.key
145
- }
146
-
147
- _excludeKeys () {
148
- if (!Array.isArray(this.excludeKey)) {
149
- return [this.excludeKey]
150
- }
151
-
152
- return this.excludeKey
153
- }
154
- }
155
-
156
- module.exports = Decrypt
@@ -1,213 +0,0 @@
1
- const fsx = require('./../helpers/fsx')
2
- const path = require('path')
3
- const picomatch = require('picomatch')
4
- const { encrypted, scan } = require('@dotenvx/primitives')
5
-
6
- const TYPE_ENV_FILE = 'envFile'
7
-
8
- const Errors = require('./../helpers/errors')
9
-
10
- const {
11
- determine
12
- } = require('./../helpers/envResolution')
13
-
14
- const {
15
- keyNamesForEnvFile,
16
- keyValues
17
- } = require('./../helpers/keyResolution')
18
-
19
- const {
20
- encryptValue,
21
- isPublicKey,
22
- provision,
23
- provisionWithPrivateKey
24
- } = require('./../helpers/cryptography')
25
-
26
- const replace = require('./../helpers/replace')
27
- const detectEncoding = require('./../helpers/detectEncoding')
28
- const SAMPLE_ENV_KIT = require('./../helpers/kits/sample')
29
-
30
- class Encrypt {
31
- constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false, noCreate = false, token = undefined, options = {}) {
32
- this.envs = determine(envs, process.env)
33
- this.key = key
34
- this.excludeKey = excludeKey
35
- this.envKeysFilepath = envKeysFilepath
36
- this.noArmor = noArmor
37
- this.noCreate = noCreate
38
- this.token = token
39
- this.selectKeyStorage = options.selectKeyStorage
40
- this.command = options.command
41
-
42
- this.processedEnvs = []
43
- this.changedFilepaths = new Set()
44
- this.unchangedFilepaths = new Set()
45
- }
46
-
47
- async run () {
48
- // example
49
- // envs [
50
- // { type: 'envFile', value: '.env' }
51
- // ]
52
-
53
- this.keys = this._keys()
54
- const excludeKeys = this._excludeKeys()
55
-
56
- this.exclude = picomatch(excludeKeys)
57
- this.include = picomatch(this.keys, { ignore: excludeKeys })
58
-
59
- for (const env of this.envs) {
60
- if (env.type === TYPE_ENV_FILE) {
61
- await this._encryptEnvFile(env.value)
62
- }
63
- }
64
-
65
- return {
66
- processedEnvs: this.processedEnvs,
67
- changedFilepaths: [...this.changedFilepaths],
68
- unchangedFilepaths: [...this.unchangedFilepaths]
69
- }
70
- }
71
-
72
- async _encryptEnvFile (envFilepath) {
73
- const row = {}
74
- row.keys = []
75
- row.type = TYPE_ENV_FILE
76
- let fileCreated = false
77
-
78
- const filepath = path.resolve(envFilepath)
79
- row.filepath = filepath
80
- row.envFilepath = envFilepath
81
-
82
- try {
83
- const fileExists = await fsx.exists(filepath)
84
- let envSrc
85
- if (!fileExists && !this.noCreate) {
86
- envSrc = SAMPLE_ENV_KIT
87
- fileCreated = true
88
- row.kitCreated = 'sample'
89
- row.changed = true
90
- } else {
91
- const encoding = await detectEncoding(filepath)
92
- envSrc = await fsx.readFileX(filepath, { encoding })
93
- }
94
- if (envSrc.trim().length === 0) {
95
- envSrc = SAMPLE_ENV_KIT
96
- row.kitCreated = 'sample'
97
- row.changed = true
98
- }
99
- const envParsed = scan(envSrc).parsed
100
-
101
- let publicKey
102
- let privateKey
103
-
104
- const { publicKeyName, privateKeyName } = keyNamesForEnvFile(envFilepath)
105
- const { publicKeyValue, privateKeyValue } = await keyValues(envFilepath, {
106
- keysFilepath: this.envKeysFilepath,
107
- noArmor: this.noArmor,
108
- command: this.command
109
- })
110
-
111
- // first pass - provision
112
- if (!privateKeyValue && !publicKeyValue) {
113
- const prov = await provision({
114
- envSrc,
115
- envFilepath,
116
- keysFilepath: this.envKeysFilepath,
117
- noArmor: this.noArmor,
118
- token: this.token,
119
- selectKeyStorage: this.selectKeyStorage,
120
- command: this.command
121
- })
122
- envSrc = prov.envSrc
123
- publicKey = prov.publicKey
124
- privateKey = prov.privateKey
125
- row.localPrivateKeyAdded = prov.localPrivateKeyAdded
126
- row.remotePrivateKeyAdded = prov.remotePrivateKeyAdded
127
- row.envKeysFilepath = prov.envKeysFilepath
128
- } else if (privateKeyValue) {
129
- const prov = provisionWithPrivateKey({ envSrc, envFilepath, keysFilepath: this.envKeysFilepath, privateKeyValue, publicKeyValue, publicKeyName })
130
- publicKey = prov.publicKey
131
- privateKey = prov.privateKey
132
- envSrc = prov.envSrc
133
- } else if (publicKeyValue) {
134
- publicKey = publicKeyValue
135
- }
136
-
137
- row.publicKey = publicKey
138
- row.privateKey = privateKey
139
- row.privateKeyName = privateKeyName
140
-
141
- // iterate over all non-encrypted values and encrypt them
142
- for (const [key, values] of Object.entries(envParsed)) {
143
- // key excluded - don't encrypt it
144
- if (this.exclude(key)) {
145
- continue
146
- }
147
-
148
- // key effectively excluded (by not being in the list of includes) - don't encrypt it
149
- if (this.keys.length > 0 && !this.include(key)) {
150
- continue
151
- }
152
-
153
- const fullyEncrypted = values.every(value => encrypted(value) || isPublicKey(key))
154
- if (!fullyEncrypted) {
155
- row.keys.push(key) // track key(s)
156
-
157
- const encryptedValues = values.map(value => {
158
- if (encrypted(value) || isPublicKey(key)) {
159
- return value
160
- }
161
-
162
- try {
163
- return encryptValue(value, publicKey)
164
- } catch {
165
- throw new Errors({ publicKeyName, publicKey }).invalidPublicKey()
166
- }
167
- })
168
-
169
- // once newSrc is built write it out
170
- envSrc = replace(envSrc, key, encryptedValues)
171
-
172
- row.changed = true // track change
173
- }
174
- }
175
-
176
- row.envSrc = envSrc
177
- if (fileCreated) {
178
- row.changed = true
179
- }
180
- if (row.changed) {
181
- this.changedFilepaths.add(envFilepath)
182
- } else {
183
- this.unchangedFilepaths.add(envFilepath)
184
- }
185
- } catch (e) {
186
- if (e.code === 'ENOENT') {
187
- row.error = new Errors({ envFilepath, filepath }).missingEnvFile()
188
- } else {
189
- row.error = e
190
- }
191
- }
192
-
193
- this.processedEnvs.push(row)
194
- }
195
-
196
- _keys () {
197
- if (!Array.isArray(this.key)) {
198
- return [this.key]
199
- }
200
-
201
- return this.key
202
- }
203
-
204
- _excludeKeys () {
205
- if (!Array.isArray(this.excludeKey)) {
206
- return [this.excludeKey]
207
- }
208
-
209
- return this.excludeKey
210
- }
211
- }
212
-
213
- module.exports = Encrypt
@@ -1,76 +0,0 @@
1
- const Run = require('./run')
2
- const Errors = require('./../helpers/errors')
3
- const { determine } = require('./../helpers/envResolution')
4
-
5
- class Get {
6
- constructor (key, envs = [], overload = false, all = false, envKeysFilepath = null, noArmor = false, options = {}) {
7
- this.key = key
8
- this.envs = envs
9
- this.overload = overload
10
- this.all = all
11
- this.envKeysFilepath = envKeysFilepath
12
- this.noArmor = noArmor
13
- this.command = options.command
14
- }
15
-
16
- runSync () {
17
- const processEnv = { ...process.env }
18
- const envs = determine(this.envs, processEnv)
19
- const { processedEnvs } = new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor, {
20
- command: this.command
21
- }).runSync()
22
- return this._result(processedEnvs, processEnv)
23
- }
24
-
25
- async run () {
26
- const processEnv = { ...process.env }
27
- const envs = determine(this.envs, processEnv)
28
- const { processedEnvs } = await new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor, {
29
- command: this.command
30
- }).run()
31
- return this._result(processedEnvs, processEnv)
32
- }
33
-
34
- _result (processedEnvs, processEnv) {
35
- const errors = []
36
- for (const processedEnv of processedEnvs) {
37
- for (const error of processedEnv.errors) {
38
- errors.push(error)
39
- }
40
- }
41
-
42
- if (this.key) {
43
- const parsed = {}
44
- const value = processEnv[this.key]
45
- parsed[this.key] = value
46
-
47
- if (value === undefined) {
48
- errors.push(new Errors({ key: this.key }).missingKey())
49
- }
50
-
51
- return { parsed, errors }
52
- }
53
-
54
- // if user wants to return ALL envs (even prior set on machine)
55
- if (this.all) {
56
- return { parsed: processEnv, errors }
57
- }
58
-
59
- // typical scenario - return only envs that were identified in the .env file
60
- // iterate over all processedEnvs.parsed and grab from processEnv
61
- /** @type {Record<string, string>} */
62
- const parsed = {}
63
- for (const processedEnv of processedEnvs) {
64
- // parsed means we saw the key in a file or --env flag. this effectively filters out any preset machine envs - while still respecting complex evaluating, expansion, and overload. in other words, the value might be the machine value because the key was displayed in a .env file
65
- if (processedEnv.parsed) {
66
- for (const key of Object.keys(processedEnv.parsed)) {
67
- parsed[key] = processEnv[key]
68
- }
69
- }
70
- }
71
-
72
- return { parsed, errors }
73
- }
74
- }
75
-
76
- module.exports = Get
@@ -1,60 +0,0 @@
1
- const keyNamesForEnvFile = require('./../helpers/keyResolution/keyNamesForEnvFile')
2
- const keyValues = require('./../helpers/keyResolution/keyValues')
3
- const keyValuesSync = require('./../helpers/keyResolution/keyValuesSync')
4
-
5
- class Keypair {
6
- constructor (envFile = '.env', envKeysFilepath = null, noArmor = false, options = {}) {
7
- this.envFile = envFile
8
- this.envKeysFilepath = envKeysFilepath
9
- this.noArmor = noArmor
10
- this.command = options.command
11
- }
12
-
13
- runSync () {
14
- const out = {}
15
-
16
- const filepaths = this._filepaths()
17
- for (const filepath of filepaths) {
18
- const { publicKeyName, privateKeyName } = keyNamesForEnvFile(filepath)
19
- const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, {
20
- keysFilepath: this.envKeysFilepath,
21
- noArmor: this.noArmor,
22
- command: this.command
23
- })
24
-
25
- out[publicKeyName] = publicKeyValue
26
- out[privateKeyName] = privateKeyValue
27
- }
28
-
29
- return out
30
- }
31
-
32
- async run () {
33
- const out = {}
34
-
35
- const filepaths = this._filepaths()
36
- for (const filepath of filepaths) {
37
- const { publicKeyName, privateKeyName } = keyNamesForEnvFile(filepath)
38
- const { publicKeyValue, privateKeyValue } = await keyValues(filepath, {
39
- keysFilepath: this.envKeysFilepath,
40
- noArmor: this.noArmor,
41
- command: this.command
42
- })
43
-
44
- out[publicKeyName] = publicKeyValue
45
- out[privateKeyName] = privateKeyValue
46
- }
47
-
48
- return out
49
- }
50
-
51
- _filepaths () {
52
- if (!Array.isArray(this.envFile)) {
53
- return [this.envFile]
54
- }
55
-
56
- return this.envFile
57
- }
58
- }
59
-
60
- module.exports = Keypair
@@ -1,36 +0,0 @@
1
- const Session = require('../../db/session')
2
- const PostOauthToken = require('../api/postOauthToken')
3
-
4
- class LoginPoll {
5
- constructor (hostname, deviceCode, interval) {
6
- this.hostname = hostname
7
- this.deviceCode = deviceCode
8
- this.interval = interval
9
- }
10
-
11
- async run () {
12
- const sesh = new Session()
13
-
14
- while (true) {
15
- try {
16
- const data = await new PostOauthToken(this.hostname, this.deviceCode).run()
17
-
18
- if (data.access_token) {
19
- sesh.login(this.hostname, data.id, data.username, data.access_token)
20
- await sesh.notifyUpdate()
21
- return data
22
- }
23
-
24
- await new Promise(resolve => setTimeout(resolve, this.interval * 1000))
25
- } catch (error) {
26
- if (error.code === 'authorization_pending') {
27
- await new Promise(resolve => setTimeout(resolve, (this.interval + 1) * 1000))
28
- } else {
29
- throw error
30
- }
31
- }
32
- }
33
- }
34
- }
35
-
36
- module.exports = LoginPoll
@@ -1,57 +0,0 @@
1
- const { fdir: Fdir } = require('fdir')
2
- const path = require('path')
3
- const picomatch = require('picomatch')
4
-
5
- class Ls {
6
- constructor (directory = './', envFile = ['.env*'], excludeEnvFile = []) {
7
- this.ignore = ['node_modules/**', '.git/**']
8
-
9
- this.cwd = path.resolve(directory)
10
- this.envFile = envFile
11
- this.excludeEnvFile = excludeEnvFile
12
- }
13
-
14
- run () {
15
- return this._filepaths()
16
- }
17
-
18
- _filepaths () {
19
- const exclude = picomatch(this._exclude())
20
- const include = picomatch(this._patterns(), {
21
- ignore: this._exclude()
22
- })
23
-
24
- return new Fdir()
25
- .withRelativePaths()
26
- .exclude((dir, path) => exclude(path))
27
- .filter((path) => include(path))
28
- .crawl(this.cwd)
29
- .sync()
30
- }
31
-
32
- _patterns () {
33
- if (!Array.isArray(this.envFile)) {
34
- return [`**/${this.envFile}`]
35
- }
36
-
37
- return this.envFile.map(part => `**/${part}`)
38
- }
39
-
40
- _excludePatterns () {
41
- if (!Array.isArray(this.excludeEnvFile)) {
42
- return [`**/${this.excludeEnvFile}`]
43
- }
44
-
45
- return this.excludeEnvFile.map(part => `**/${part}`)
46
- }
47
-
48
- _exclude () {
49
- if (this._excludePatterns().length > 0) {
50
- return this.ignore.concat(this._excludePatterns())
51
- } else {
52
- return this.ignore
53
- }
54
- }
55
- }
56
-
57
- module.exports = Ls