forked from allure-framework/allure-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-local-deps.mjs
31 lines (28 loc) · 1010 Bytes
/
update-local-deps.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { readFile, writeFile } from "node:fs/promises";
import glob from "glob";
const res = glob.sync("./packages/*/package.json");
const localWorkspaceVersions = {};
await Promise.all(
res.map(async (packagePath) => {
const packageContent = await readFile(packagePath, "utf-8");
const { name, version } = JSON.parse(packageContent);
localWorkspaceVersions[name] = version;
}),
);
await Promise.all(
res.map(async (packagePath) => {
const packageContent = await readFile(packagePath, "utf-8");
const parsedJson = JSON.parse(packageContent);
for (const dep in parsedJson.dependencies) {
if (localWorkspaceVersions[dep]) {
parsedJson.dependencies[dep] = localWorkspaceVersions[dep];
}
}
for (const dep in parsedJson.devDependencies) {
if (localWorkspaceVersions[dep]) {
parsedJson.devDependencies[dep] = localWorkspaceVersions[dep];
}
}
await writeFile(packagePath, JSON.stringify(parsedJson, null, 2), "utf-8");
}),
);