@smithy/shared-ini-file-loader 3.1.2 → 3.1.4
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-cjs/index.js +18 -2
- package/dist-es/loadSharedConfigFiles.js +14 -2
- package/package.json +2 -2
package/dist-cjs/index.js
CHANGED
|
@@ -41,6 +41,9 @@ var getProfileName = /* @__PURE__ */ __name((init) => init.profile || process.en
|
|
|
41
41
|
__reExport(src_exports, require("././getSSOTokenFilepath"), module.exports);
|
|
42
42
|
__reExport(src_exports, require("././getSSOTokenFromFile"), module.exports);
|
|
43
43
|
|
|
44
|
+
// src/loadSharedConfigFiles.ts
|
|
45
|
+
|
|
46
|
+
|
|
44
47
|
// src/getConfigData.ts
|
|
45
48
|
var import_types = require("@smithy/types");
|
|
46
49
|
var getConfigData = /* @__PURE__ */ __name((data) => Object.entries(data).filter(([key]) => {
|
|
@@ -74,6 +77,9 @@ var import_getHomeDir2 = require("././getHomeDir");
|
|
|
74
77
|
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
75
78
|
var getCredentialsFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");
|
|
76
79
|
|
|
80
|
+
// src/loadSharedConfigFiles.ts
|
|
81
|
+
var import_getHomeDir3 = require("././getHomeDir");
|
|
82
|
+
|
|
77
83
|
// src/parseIni.ts
|
|
78
84
|
|
|
79
85
|
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
@@ -130,11 +136,21 @@ var swallowError = /* @__PURE__ */ __name(() => ({}), "swallowError");
|
|
|
130
136
|
var CONFIG_PREFIX_SEPARATOR = ".";
|
|
131
137
|
var loadSharedConfigFiles = /* @__PURE__ */ __name(async (init = {}) => {
|
|
132
138
|
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
139
|
+
const homeDir = (0, import_getHomeDir3.getHomeDir)();
|
|
140
|
+
const relativeHomeDirPrefix = "~/";
|
|
141
|
+
let resolvedFilepath = filepath;
|
|
142
|
+
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
143
|
+
resolvedFilepath = (0, import_path.join)(homeDir, filepath.slice(2));
|
|
144
|
+
}
|
|
145
|
+
let resolvedConfigFilepath = configFilepath;
|
|
146
|
+
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
147
|
+
resolvedConfigFilepath = (0, import_path.join)(homeDir, configFilepath.slice(2));
|
|
148
|
+
}
|
|
133
149
|
const parsedFiles = await Promise.all([
|
|
134
|
-
(0, import_slurpFile.slurpFile)(
|
|
150
|
+
(0, import_slurpFile.slurpFile)(resolvedConfigFilepath, {
|
|
135
151
|
ignoreCache: init.ignoreCache
|
|
136
152
|
}).then(parseIni).then(getConfigData).catch(swallowError),
|
|
137
|
-
(0, import_slurpFile.slurpFile)(
|
|
153
|
+
(0, import_slurpFile.slurpFile)(resolvedFilepath, {
|
|
138
154
|
ignoreCache: init.ignoreCache
|
|
139
155
|
}).then(parseIni).catch(swallowError)
|
|
140
156
|
]);
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
+
import { join } from "path";
|
|
1
2
|
import { getConfigData } from "./getConfigData";
|
|
2
3
|
import { getConfigFilepath } from "./getConfigFilepath";
|
|
3
4
|
import { getCredentialsFilepath } from "./getCredentialsFilepath";
|
|
5
|
+
import { getHomeDir } from "./getHomeDir";
|
|
4
6
|
import { parseIni } from "./parseIni";
|
|
5
7
|
import { slurpFile } from "./slurpFile";
|
|
6
8
|
const swallowError = () => ({});
|
|
7
9
|
export const CONFIG_PREFIX_SEPARATOR = ".";
|
|
8
10
|
export const loadSharedConfigFiles = async (init = {}) => {
|
|
9
11
|
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
12
|
+
const homeDir = getHomeDir();
|
|
13
|
+
const relativeHomeDirPrefix = "~/";
|
|
14
|
+
let resolvedFilepath = filepath;
|
|
15
|
+
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
16
|
+
resolvedFilepath = join(homeDir, filepath.slice(2));
|
|
17
|
+
}
|
|
18
|
+
let resolvedConfigFilepath = configFilepath;
|
|
19
|
+
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
20
|
+
resolvedConfigFilepath = join(homeDir, configFilepath.slice(2));
|
|
21
|
+
}
|
|
10
22
|
const parsedFiles = await Promise.all([
|
|
11
|
-
slurpFile(
|
|
23
|
+
slurpFile(resolvedConfigFilepath, {
|
|
12
24
|
ignoreCache: init.ignoreCache,
|
|
13
25
|
})
|
|
14
26
|
.then(parseIni)
|
|
15
27
|
.then(getConfigData)
|
|
16
28
|
.catch(swallowError),
|
|
17
|
-
slurpFile(
|
|
29
|
+
slurpFile(resolvedFilepath, {
|
|
18
30
|
ignoreCache: init.ignoreCache,
|
|
19
31
|
})
|
|
20
32
|
.then(parseIni)
|