Skip to content

Commit 7dde09e

Browse files
author
DylanBulmer
committed
update node modules to be a record
1 parent 4cd3451 commit 7dde09e

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codrjs/config",
3-
"version": "1.0.3",
3+
"version": "1.0.3-patch1",
44
"description": "Codr configuration, unified",
55
"main": "./cjs/index.js",
66
"module": "./esm/index.js",

src/config/NodeConfig.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
export const NodeConfig: {
22
env: "production" | "developement" | "testing";
33
version: string;
4-
modules: string[];
4+
modules: Record<string, string>;
55
yarnVersion: string;
66
} = {
77
env: process.env.NODE_ENV as "production" | "developement" | "testing",
88
version: process.env.NODE_VERSION as string,
99
modules: Object.keys(process.env)
1010
.filter(m => /npm_package_dependencies_/g.test(m))
11-
.map(m => m.replace(/npm_package_dependencies_/g, ""))
12-
.map(m =>
13-
m
11+
.map(m => [m, process.env[m]] as [string, string])
12+
.map(m => m[0].replace(/npm_package_dependencies_/g, ""))
13+
.map(m => [
14+
m[0]
1415
.split("_")
1516
.map((p, idx) =>
1617
p === ""
1718
? "@"
18-
: idx === m.split("_").length - 1 && m.split("_").length !== 1
19+
: idx === m[0].split("_").length - 1 && m[0].split("_").length !== 1
1920
? `/${p}`
2021
: p,
2122
)
2223
.join(""),
23-
),
24+
m[1],
25+
])
26+
.reduce((acc, curr) => {
27+
return (acc[curr[0]] = curr[1]);
28+
}, {}),
2429
yarnVersion: process.env.YARN_VERSION as string,
2530
};

0 commit comments

Comments
 (0)