Comments (11)
What's the advantage?
Emmm... You can ignore the way I suggest to use it.
But refactor by command
the code will be easy to read.
When i use dotenv-cli
without <My command>
,
Throw a Error: [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type undefined
It took me a long time to find out the cause of the problem.
Line 27 in 0bef67a
Because argv._[0]
is undefined
In addition, I hope that my use of the scene can bring a little inspiration
The following is my usage scenario:
Normally, i just need the default .env
.
So, i just need configure script like this in package.json
{
"scripts": {
"dev": "dotenv next dev"
},
}
it is work well too
{
"scripts": {
"dev": "dotenv -- next dev"
},
}
But, some time i need to debug in diff deploy environment.
And i do not want to configure many script in package.json
, because they are not commonly used.
I choice the first config, so that i can do something like this:
yarn run dev -e .env.debug.local
Woo~, everything in my control
The command next dev
support a arg --port
to control dev server port
if i use the arg --port
base script dev
yarn run dev -e .env.debug.local -- --port 3001
// it is seem work well, actually not
Because yarn will ignore the first --
warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
// what you excute command is
// yarn run dev -e .env.debug.local --port 3001
yarn run dev -e .env.debug.local -- -- --port 3001
npm run dev -e .env.debug.local -- -- --port 3001
// work well, but too many `--`, and It's hard to understand what command did
from dotenv-cli.
I had a similar problem and it was fixed by adding --.
Thanks for the tip, @entropitor
from dotenv-cli.
Does dotenv mvn exec:java -- -Dexec.args="-g -f"
work?
from dotenv-cli.
So how do you run dotenv node --experimental-modules server.mjs
?
It just hangs without doing anything...
from dotenv-cli.
I'm guessing dotenv node -- --experimental-modules server.mjs
.
Basically any command line flag you want to parse to a the subprocess you're creating should be behind the --
as dotenv-cli
will ignore everything after there
from dotenv-cli.
Maybe we can refactor by use commander
It is simple to write a command tool.
Then We can use dotenv-cli
like this
dotenv -e .env1 .env2 .env3 command <My command with args>
from dotenv-cli.
@xyy94813 What's the advantage? You can already do this, as describe in this issue and by the README: https://github.com/entropitor/dotenv-cli#flags-to-the-underlying-command
You just need to add --
dotenv -e .env1 .env2 .env3 -- command <My command with args>
from dotenv-cli.
dotenv MyCommand -e XXX
not equal dotenv -- MyCommand -e XXX
It is a bit counterintuitive
from dotenv-cli.
The -- is very common see e.g. https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash
And your use-case is exactly an example of one why we want such a thing. Without it, the -e .env.debug.local
flag would be passed to the next dev
executable, NOT to dotenv
Feel free to fork the repo and publish your own version btw, but I believe it's better if we do use the --
from dotenv-cli.
I have a similar problem and tried with "--" but it still doesn't work.
My example:
I have the following script in my package.json
"test": "dotenv -e .env.test && docker compose up -d && yarn prisma migrate deploy && jest -i"
When I run yarn test
it doesn't work.
How should I write my command? @entropitor
from dotenv-cli.
dotenv -e .env.test -- bash -c "docker compose up -d && yarn prisma migrate deploy && jest -i"
If it doesn't, I don't know by hard. This is basic shell priority, this CLI doesn't do anything special
from dotenv-cli.
Related Issues (20)
- Documentation should recommend use of "--" separator HOT 2
- Specify directory containing .env files HOT 3
- its adding double quotes HOT 1
- [Bug]Runtime error when using "-p" option HOT 3
- [Documentation] Clarify if the files specified by `-e` are read in addition to, or instead of the default ones HOT 1
- [feature] Ability to specify the exact sequence of .env files to process using absolute paths HOT 1
- COPYRIGHT is missing HOT 1
- sorry HOT 1
- dotenv-expand: TypeError: Cannot read property 'split' of undefined HOT 6
- .env.local should have higher priority than .env.<environment> HOT 2
- unable to run command with prefix HOT 1
- Fail to load env HOT 4
- Allow setting variable with a value containing strings HOT 7
- Change load order of multiple .env files HOT 2
- Override system variables HOT 2
- Conflicting options: 'override' and 'cascade' HOT 5
- Loading Vault files HOT 4
- Dotenv-cli removes output colors HOT 1
- npm ERR! could not determine executable to run HOT 1
- Add longopts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotenv-cli.