@teqfw/di 0.21.1 → 0.22.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/RELEASE.md +4 -0
- package/package.json +1 -1
- package/src/Container/Resolver.js +14 -1
package/RELEASE.md
CHANGED
package/package.json
CHANGED
|
@@ -26,16 +26,20 @@ export default class TeqFw_Di_Container_Resolver {
|
|
|
26
26
|
constructor() {
|
|
27
27
|
// VARS
|
|
28
28
|
const _regNs = {};
|
|
29
|
+
let _isWindows = false; // flag of the runtime env - win or *nix/web
|
|
29
30
|
let _namespaces = [];
|
|
30
31
|
let _ps = '/'; // web & unix path separator
|
|
31
32
|
|
|
32
33
|
// INSTANCE METHODS
|
|
33
34
|
|
|
34
35
|
this.addNamespaceRoot = function (ns, path, ext) {
|
|
36
|
+
const lead = (_isWindows) ? path.replace(/^\\/, '') : path; // remove leading backslash for Win
|
|
37
|
+
const norm = lead.replace(/\\/g, '/'); // replace all windows path separators
|
|
38
|
+
const root = (_isWindows) ? `file://${norm}` : norm;
|
|
35
39
|
_regNs[ns] = {
|
|
36
40
|
[KEY_EXT]: ext ?? Defs.EXT,
|
|
37
41
|
[KEY_NS]: ns,
|
|
38
|
-
[KEY_PATH]:
|
|
42
|
+
[KEY_PATH]: root,
|
|
39
43
|
};
|
|
40
44
|
_namespaces = Object.keys(_regNs).sort((a, b) => b.localeCompare(a));
|
|
41
45
|
};
|
|
@@ -61,5 +65,14 @@ export default class TeqFw_Di_Container_Resolver {
|
|
|
61
65
|
return `${root}${_ps}${file}.${ext}`;
|
|
62
66
|
} else return moduleName;
|
|
63
67
|
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 'true' - to use '\' as path separator to resolve paths.
|
|
71
|
+
* @param {boolean} isWindows
|
|
72
|
+
*/
|
|
73
|
+
this.setWindowsEnv = function (isWindows = true) {
|
|
74
|
+
_isWindows = isWindows;
|
|
75
|
+
_ps = (isWindows) ? '\\' : '/';
|
|
76
|
+
};
|
|
64
77
|
}
|
|
65
78
|
};
|