@cloudcannon/configuration-loader 0.0.9 → 0.0.10
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/dist/load.js +13 -4
- package/package.json +1 -1
package/dist/load.js
CHANGED
|
@@ -8,7 +8,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
8
8
|
};
|
|
9
9
|
import { globSync } from 'node:fs';
|
|
10
10
|
import { readFile } from 'node:fs/promises';
|
|
11
|
-
import { dirname, resolve } from 'node:path';
|
|
11
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
12
12
|
import { mergeConfiguration } from "./loader.js";
|
|
13
13
|
/**
|
|
14
14
|
* Attempts to load the js-yaml package dynamically.
|
|
@@ -86,11 +86,20 @@ export async function loadConfiguration(configPath, options) {
|
|
|
86
86
|
// Glob operations are typically fast (just directory traversal), while file
|
|
87
87
|
// reading (handled by loadConfigFile) is the slower I/O operation.
|
|
88
88
|
findFilesMatchingGlobs: (globs) => {
|
|
89
|
-
const resolvedGlobs = globs.
|
|
89
|
+
const resolvedGlobs = globs.flatMap((g) => {
|
|
90
90
|
if (g.startsWith('!')) {
|
|
91
|
-
|
|
91
|
+
const pattern = g.slice(1);
|
|
92
|
+
const resolved = resolve(configDir, pattern.startsWith('/') ? pattern.slice(1) : pattern);
|
|
93
|
+
if (relative(configDir, resolved).startsWith('..')) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return [`!${resolved}`];
|
|
92
97
|
}
|
|
93
|
-
|
|
98
|
+
const resolved = resolve(configDir, g.startsWith('/') ? g.slice(1) : g);
|
|
99
|
+
if (relative(configDir, resolved).startsWith('..')) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
return [resolved];
|
|
94
103
|
});
|
|
95
104
|
return globSync(resolvedGlobs);
|
|
96
105
|
},
|