Skip to content

Commit

Permalink
update node modules to be a record
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanBulmer committed Apr 9, 2023
1 parent 4cd3451 commit 7dde09e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codrjs/config",
"version": "1.0.3",
"version": "1.0.3-patch1",
"description": "Codr configuration, unified",
"main": "./cjs/index.js",
"module": "./esm/index.js",
Expand Down
17 changes: 11 additions & 6 deletions src/config/NodeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
export const NodeConfig: {
env: "production" | "developement" | "testing";
version: string;
modules: string[];
modules: Record<string, string>;
yarnVersion: string;
} = {
env: process.env.NODE_ENV as "production" | "developement" | "testing",
version: process.env.NODE_VERSION as string,
modules: Object.keys(process.env)
.filter(m => /npm_package_dependencies_/g.test(m))
.map(m => m.replace(/npm_package_dependencies_/g, ""))
.map(m =>
m
.map(m => [m, process.env[m]] as [string, string])
.map(m => m[0].replace(/npm_package_dependencies_/g, ""))
.map(m => [
m[0]
.split("_")
.map((p, idx) =>
p === ""
? "@"
: idx === m.split("_").length - 1 && m.split("_").length !== 1
: idx === m[0].split("_").length - 1 && m[0].split("_").length !== 1
? `/${p}`
: p,
)
.join(""),
),
m[1],
])
.reduce((acc, curr) => {
return (acc[curr[0]] = curr[1]);
}, {}),
yarnVersion: process.env.YARN_VERSION as string,
};

0 comments on commit 7dde09e

Please sign in to comment.