Skip to content

Commit 0842384

Browse files
authored
fixes #415 (#417)
* readme updates + commonjs issue * make order dotenv-flow * cleanup * 3.4.8
1 parent 4d5d11a commit 0842384

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
$ npm install -D react-native-dotenv
1616
```
1717

18+
If you are using Yarn:
19+
20+
```sh
21+
$ yarn add -D react-native-dotenv
22+
```
23+
1824
**Breaking changes**: moving from `v0.x` to `v2.x` changes both the setup and usage of this package. Please see the [migration guide](https://github.com/goatandsheep/react-native-dotenv/wiki/Migration-Guide).
1925

2026
Many have been asking about the reasons behind recent changes in this repo. Please see the [story wiki page](https://github.com/goatandsheep/react-native-dotenv/wiki/Story-of-this-repo).

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const {readFileSync, statSync} = require('fs')
1+
const fs = require('fs')
22
const path = require('path')
33
const dotenv = require('dotenv')
44

55
function parseDotenvFile(path, verbose = false) {
66
let content
77

88
try {
9-
content = readFileSync(path)
9+
content = fs.readFileSync(path)
1010
} catch (error) {
1111
// The env file does not exist.
1212
if (verbose) {
@@ -49,7 +49,7 @@ function safeObjectAssign(targetObject, sourceObject, exceptions = []) {
4949

5050
function mtime(filePath) {
5151
try {
52-
return statSync(filePath).mtimeMs
52+
return fs.statSync(filePath).mtimeMs
5353
} catch {
5454
return null
5555
}
@@ -81,21 +81,21 @@ module.exports = (api, options) => {
8181
}
8282

8383
api.cache.using(() => mtime(options.path))
84-
api.cache.using(() => mtime(localFilePath))
8584
api.cache.using(() => mtime(modeFilePath))
85+
api.cache.using(() => mtime(localFilePath))
8686
api.cache.using(() => mtime(modeLocalFilePath))
8787

8888
const dotenvTemporary = undefObjectAssign({}, process.env)
8989
const parsed = parseDotenvFile(options.path, options.verbose)
9090
const localParsed = parseDotenvFile(localFilePath, options.verbose)
9191
const modeParsed = parseDotenvFile(modeFilePath, options.verbose)
9292
const modeLocalParsed = parseDotenvFile(modeLocalFilePath, options.verbose)
93-
env = (options.safe) ? safeObjectAssign(undefObjectAssign(undefObjectAssign(undefObjectAssign(parsed, localParsed), modeParsed), modeLocalParsed), dotenvTemporary, ['NODE_ENV', 'BABEL_ENV', options.envName])
94-
: undefObjectAssign(undefObjectAssign(undefObjectAssign(undefObjectAssign(parsed, localParsed), modeParsed), modeLocalParsed), dotenvTemporary)
93+
env = (options.safe) ? safeObjectAssign(undefObjectAssign(undefObjectAssign(undefObjectAssign(parsed, modeParsed), localParsed), modeLocalParsed), dotenvTemporary, ['NODE_ENV', 'BABEL_ENV', options.envName])
94+
: undefObjectAssign(undefObjectAssign(undefObjectAssign(undefObjectAssign(parsed, modeParsed), localParsed), modeLocalParsed), dotenvTemporary)
9595

9696
api.addExternalDependency(path.resolve(options.path))
97-
api.addExternalDependency(path.resolve(localFilePath))
9897
api.addExternalDependency(path.resolve(modeFilePath))
98+
api.addExternalDependency(path.resolve(localFilePath))
9999
api.addExternalDependency(path.resolve(modeLocalFilePath))
100100

101101
return ({

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-dotenv",
3-
"version": "3.4.7",
3+
"version": "3.4.8",
44
"description": "Load environment variables using import statements.",
55
"repository": "github:goatandsheep/react-native-dotenv",
66
"homepage": "https://github.com/goatandsheep/react-native-dotenv",
@@ -26,13 +26,17 @@
2626
"dotenv": "^16.0.3"
2727
},
2828
"devDependencies": {
29+
"@babel/core": "^7.20.5",
2930
"codecov": "^3.8.3",
3031
"jest": "29.3.1",
3132
"jest-junit": "^15.0.0",
3233
"xo": "^0.53.1"
3334
},
3435
"author": "Kemal Ahmed",
3536
"license": "MIT",
37+
"files": [
38+
"index.js"
39+
],
3640
"jest": {
3741
"testEnvironment": "node",
3842
"testPathIgnorePatterns": [
@@ -58,7 +62,6 @@
5862
]
5963
},
6064
"peerDependencies": {
61-
"@babel/core": "^7.20.5",
6265
"@babel/runtime": "^7.20.6"
6366
},
6467
"resolutions": {

0 commit comments

Comments
 (0)