mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 03:19:36 +01:00
feat: new environment variable (storage path) (#2993)
* WIP: port PR#2199 to master into 5.x * port PR#2199 to master to 5.x - env.variables.md * port PR#2199 to master to 5.x - config.spec * Update config.spec.ts * Update config.spec.ts * fix format Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
parent
63fc4d1baf
commit
681dc821aa
@ -41,3 +41,7 @@ The default header to identify the protocol is `X-Forwarded-Proto`, but there ar
|
||||
```
|
||||
$ VERDACCIO_FORWARDED_PROTO=CloudFront-Forwarded-Proto verdaccio --listen 5000
|
||||
```
|
||||
|
||||
#### VERDACCIO_STORAGE_PATH
|
||||
|
||||
By default, the storage is taken from config file, but using this variable allows to set it from environment variable.
|
||||
|
@ -38,7 +38,7 @@ class Config implements AppConfig {
|
||||
const self = this;
|
||||
this.logger = LoggerApi.logger;
|
||||
this.self_path = config.self_path;
|
||||
this.storage = config.storage;
|
||||
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
||||
this.plugins = config.plugins;
|
||||
|
||||
for (const configProp in config) {
|
||||
|
@ -91,7 +91,18 @@ describe('Config file', () => {
|
||||
expect(config.auth.htpasswd.file).toBe('./htpasswd');
|
||||
checkDefaultConfPackages(config);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Config file', () => {});
|
||||
test('with process.env.VERDACCIO_STORAGE_PATH', () => {
|
||||
const testPath = '/builds/project/foo/bar/baz';
|
||||
// @ts-ignore
|
||||
process.env.VERDACCIO_STORAGE_PATH = testPath;
|
||||
try {
|
||||
const config = new Config(parseConfigFile(resolveConf('default')));
|
||||
expect(config.storage).toBe(testPath);
|
||||
} finally {
|
||||
// @ts-ignore
|
||||
delete process.env.VERDACCIO_STORAGE_PATH;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user