mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-21 07:29:37 +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_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;
|
const self = this;
|
||||||
this.logger = LoggerApi.logger;
|
this.logger = LoggerApi.logger;
|
||||||
this.self_path = config.self_path;
|
this.self_path = config.self_path;
|
||||||
this.storage = config.storage;
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
||||||
this.plugins = config.plugins;
|
this.plugins = config.plugins;
|
||||||
|
|
||||||
for (const configProp in config) {
|
for (const configProp in config) {
|
||||||
|
@ -91,7 +91,18 @@ describe('Config file', () => {
|
|||||||
expect(config.auth.htpasswd.file).toBe('./htpasswd');
|
expect(config.auth.htpasswd.file).toBe('./htpasswd');
|
||||||
checkDefaultConfPackages(config);
|
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