near-cli
near-cli copied to clipboard
Near CLI looks at CWD for a src/config.js file which can cause interference
Describe the bug
Essentially in the near cli on [this line](https://github.com/near/near-cli/blob/509846163695ba227f4ad5dc070b56040fcd9bab/get-config.js#L3) it tries an look for a config.js file within the users current working directory. To me this shouldn’t be the case, it should use a default unless a user explicitly specifies otherwise like --config <your config.js file>
...
const configPath = process.cwd() + '/src/config';
const nearEnv = process.env.NEAR_ENV || process.env.NODE_ENV || 'development';
try
{ const config = require(configPath)(nearEnv); return config; }
catch (e)
{ ... }
...
To Reproduce Reproduction for this issue is tricky as you will see different results depending on what is in the config.js file.
Steps to reproduce the behavior:
1. Run near within a project directory that has a src/config.js file
2. See error
❯ near
/Some/project/directory/src/config.js:L99
export default function someMethod() {
^^^^^^
SyntaxError: Unexpected token 'export'
Expected behavior
I expect that when I run the near command that I will get determintic behaviour regardless of which directory I am in. I expect the the near cli would not be effected by external files within my current directory.
Desktop (please complete the following information):
- OS: MacOS
- Version: 2.0.1
Let me know what needs to be done and I can open a PR to address this, thanks!
I agree. This has bugged me quite a bit.
near dev-deploy
For example also fails (sometimes silently depending on your setup) if this config file specifies an object that contains additional fields it doesn't recognize...
Odd.
Yep, one of my least favorite "features" of near-cli
@chadoh Would it be safe to remove as @MaximusHaximus suggested?

cc @vgrichina
@vgrichina @MaximusHaximus @mattlockyer
Any update?