@travetto/config 3.2.3 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/parser/json.ts +1 -1
- package/src/parser/properties.ts +2 -2
- package/src/parser/yaml.ts +1 -1
- package/src/source/file.ts +5 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Configuration support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yaml",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"directory": "module/config"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/di": "^3.
|
|
30
|
-
"@travetto/schema": "^3.
|
|
31
|
-
"@travetto/yaml": "^3.
|
|
29
|
+
"@travetto/di": "^3.3.0",
|
|
30
|
+
"@travetto/schema": "^3.3.0",
|
|
31
|
+
"@travetto/yaml": "^3.3.0"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
|
34
34
|
"displayName": "Configuration"
|
package/src/parser/json.ts
CHANGED
package/src/parser/properties.ts
CHANGED
|
@@ -33,7 +33,7 @@ export class PropertiesConfigParser implements ConfigParser {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
ext = ['properties'];
|
|
36
|
+
ext = ['.properties'];
|
|
37
37
|
|
|
38
38
|
parse(text: string): ConfigData {
|
|
39
39
|
const out: ConfigData = {};
|
|
@@ -41,7 +41,7 @@ export class PropertiesConfigParser implements ConfigParser {
|
|
|
41
41
|
|
|
42
42
|
for (let i = 0; i < lines.length; i++) {
|
|
43
43
|
let line = lines[i];
|
|
44
|
-
while (i <
|
|
44
|
+
while (i < lines.length && line.endsWith('\\')) {
|
|
45
45
|
line = `${line.replace(/\\$/, '')}${lines[i += 1].trimStart()}`;
|
|
46
46
|
}
|
|
47
47
|
const entry = PropertiesConfigParser.parseLine(line);
|
package/src/parser/yaml.ts
CHANGED
package/src/source/file.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { path } from '@travetto/manifest';
|
|
1
2
|
import { FileQueryProvider } from '@travetto/base';
|
|
2
3
|
import { DependencyRegistry, InjectableFactory } from '@travetto/di';
|
|
3
4
|
|
|
@@ -29,22 +30,17 @@ export class FileConfigSource extends FileQueryProvider implements ConfigSource
|
|
|
29
30
|
const parsers = await Promise.all(parserClasses.map(x => DependencyRegistry.getInstance<ConfigParser>(x.class, x.qualifier)));
|
|
30
31
|
|
|
31
32
|
// Register parsers
|
|
32
|
-
this.parsers =
|
|
33
|
-
for (const par of parsers) {
|
|
34
|
-
for (const ext of par.ext) {
|
|
35
|
-
this.parsers[ext] = par;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
33
|
+
this.parsers = Object.fromEntries(parsers.flatMap(p => p.ext.map(e => [e, p])));
|
|
38
34
|
|
|
39
|
-
this.extMatch = parsers.length ? new RegExp(`
|
|
35
|
+
this.extMatch = parsers.length ? new RegExp(`(${Object.keys(this.parsers).join('|').replaceAll('.', '[.]')})`) : /^$/;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
async getValues(profiles: string[]): Promise<ConfigValue[]> {
|
|
43
39
|
const out: ConfigValue[] = [];
|
|
44
40
|
|
|
45
41
|
for await (const file of this.query(f => this.extMatch.test(f))) {
|
|
46
|
-
const ext =
|
|
47
|
-
const profile =
|
|
42
|
+
const ext = path.extname(file);
|
|
43
|
+
const profile = path.basename(file, ext);
|
|
48
44
|
if (!profiles.includes(profile) || !this.parsers[ext]) {
|
|
49
45
|
continue;
|
|
50
46
|
}
|