Skip to content
This repository was archived by the owner on Nov 13, 2020. It is now read-only.

Commit 3511e27

Browse files
committed
Merge master
2 parents d8eefac + 9753b0f commit 3511e27

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"repository": {
1919
"type": "git",
20-
"url": "http://github.com/romakita/json-properties"
20+
"url": "https://github.com/romakita/json-properties.git"
2121
},
2222
"keywords": [
2323
"ts",

readme.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,32 @@ export class Foo {
105105

106106
//or with Properties Api
107107

108-
console.log('wsdl', Properties.getValue('wsdl')); // wsdl => {"wsdl1":"..."}
108+
console.log('wsdl', Properties.get('wsdl')); // wsdl => {"wsdl1":"..."}
109109
}
110110
}
111111
```
112+
> **Note** : All properties returned by `@Value` or `Properties.getValue` are **immutable**.
112113
113-
**Note** : All properties returned by `@Value` or `Properties.getValue` are **immutable**.
114+
115+
### From Env
116+
117+
Define your env variable:
118+
119+
```bash
120+
export path__to__var = "1000"
121+
```
122+
123+
Then use `@EnvValue`:
124+
125+
```typescript
126+
import {Value, Properties} from 'ts-json-properties';
127+
128+
export class Foo {
129+
@EventValue('path.to.var')
130+
private documents1: string;
131+
}
132+
```
133+
> Note: if the env value is undefined, the value will be retrieved from properties.json
114134
115135
## Test
116136

src/decorators/envValue.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {parse} from "../utils/parse";
21
import {Properties} from "../utils/Properties";
32

43
export function EnvValue(expression: string, defaultValue?: any) {
@@ -7,7 +6,7 @@ export function EnvValue(expression: string, defaultValue?: any) {
76

87
if (delete target[propertyKey]) {
98

10-
let value = parse(expression, process.env);
9+
let value = process.env[expression.replace(/\./gi, "__")];
1110

1211
Object.defineProperty(target, propertyKey, {
1312

0 commit comments

Comments
 (0)