@dotenvx/dotenvx 1.11.1 → 1.11.3
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/CHANGELOG.md +13 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/cli/actions/get.js +3 -1
- package/src/lib/helpers/colorDepth.js +14 -1
- package/src/lib/helpers/detectEncoding.js +28 -0
- package/src/lib/services/run.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.11.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.11.3...main)
|
|
6
|
+
|
|
7
|
+
## 1.11.3
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* fallback to `process.env.TERM` for color depth where deno and bun do not support it ([#360](https://github.com/dotenvx/dotenvx/pull/360))
|
|
12
|
+
|
|
13
|
+
## 1.11.2
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* detect encoding when reading `.env*` file on `run/get` ([#359](https://github.com/dotenvx/dotenvx/pull/359))
|
|
6
18
|
|
|
7
19
|
## 1.11.1
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -256,7 +256,7 @@ More examples
|
|
|
256
256
|
```sh
|
|
257
257
|
$ dotnet new console -n HelloWorld -o HelloWorld
|
|
258
258
|
$ cd HelloWorld
|
|
259
|
-
$ echo "HELLO=World"
|
|
259
|
+
$ echo "HELLO=World" | Out-File -FilePath .env -Encoding utf8
|
|
260
260
|
$ echo 'Console.WriteLine($"Hello {Environment.GetEnvironmentVariable("HELLO")}");' > Program.cs
|
|
261
261
|
|
|
262
262
|
$ dotenvx run -- dotnet run
|
package/package.json
CHANGED
package/src/cli/actions/get.js
CHANGED
|
@@ -5,7 +5,9 @@ const conventions = require('./../../lib/helpers/conventions')
|
|
|
5
5
|
const main = require('./../../lib/main')
|
|
6
6
|
|
|
7
7
|
function get (key) {
|
|
8
|
-
|
|
8
|
+
if (key) {
|
|
9
|
+
logger.debug(`key: ${key}`)
|
|
10
|
+
}
|
|
9
11
|
|
|
10
12
|
const options = this.opts()
|
|
11
13
|
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
const { WriteStream } = require('tty')
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const getColorDepth = () => {
|
|
4
|
+
try {
|
|
5
|
+
return WriteStream.prototype.getColorDepth()
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const term = process.env.TERM
|
|
8
|
+
|
|
9
|
+
if (term && (term.includes('256color') || term.includes('xterm'))) {
|
|
10
|
+
return 8 // 256 colors
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return 4
|
|
14
|
+
}
|
|
15
|
+
}
|
|
3
16
|
|
|
4
17
|
module.exports = { getColorDepth }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
function detectEncoding (filepath) {
|
|
4
|
+
const buffer = fs.readFileSync(filepath)
|
|
5
|
+
|
|
6
|
+
// check for UTF-16LE BOM (Byte Order Mark)
|
|
7
|
+
if (buffer.length >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
|
8
|
+
return 'utf16le'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* c8 ignore start */
|
|
12
|
+
// check for UTF-8 BOM
|
|
13
|
+
if (buffer.length >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
|
14
|
+
return 'utf8'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Check if the file is entirely US-ASCII (0x00 - 0x7F), which is valid UTF-8
|
|
18
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
19
|
+
if (buffer[i] > 0x7F) {
|
|
20
|
+
break
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/* c8 ignore stop */
|
|
24
|
+
|
|
25
|
+
return 'utf8'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = detectEncoding
|
package/src/lib/services/run.js
CHANGED
|
@@ -15,6 +15,7 @@ const parseDecryptEvalExpand = require('./../helpers/parseDecryptEvalExpand')
|
|
|
15
15
|
const parseEnvironmentFromDotenvKey = require('./../helpers/parseEnvironmentFromDotenvKey')
|
|
16
16
|
const smartDotenvPrivateKey = require('./../helpers/smartDotenvPrivateKey')
|
|
17
17
|
const guessPrivateKeyFilename = require('./../helpers/guessPrivateKeyFilename')
|
|
18
|
+
const detectEncoding = require('./../helpers/detectEncoding')
|
|
18
19
|
|
|
19
20
|
class Run {
|
|
20
21
|
constructor (envs = [], overload = false, DOTENV_KEY = '', processEnv = process.env) {
|
|
@@ -89,7 +90,8 @@ class Run {
|
|
|
89
90
|
|
|
90
91
|
const filepath = path.resolve(envFilepath)
|
|
91
92
|
try {
|
|
92
|
-
const
|
|
93
|
+
const encoding = detectEncoding(filepath)
|
|
94
|
+
const src = fs.readFileSync(filepath, { encoding })
|
|
93
95
|
this.readableFilepaths.add(envFilepath)
|
|
94
96
|
|
|
95
97
|
// if DOTENV_PRIVATE_KEY_* already set in process.env then use it
|