-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathupdate_deps.mjs
More file actions
26 lines (23 loc) · 1.01 KB
/
update_deps.mjs
File metadata and controls
26 lines (23 loc) · 1.01 KB
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
import { readdir, readFile, writeFile } from "fs/promises";
import pkg from './package.json' with {type: "json"};
import { existsSync } from "fs";
const packageDirs = await readdir("packages");
for (const packageDir of packageDirs) {
console.log(`Updating ${packageDir}`);
const packageJsonPath = `packages/${packageDir}/package.json`;
if (!existsSync(packageJsonPath)) {
continue;
}
const packageJson = await readFile(packageJsonPath, "utf8").then(JSON.parse);
if (packageJson.dependencies) {
for (const dep of Object.keys(packageJson.dependencies)) {
if (pkg.dependencies[dep] && packageJson.dependencies[dep] !== pkg.dependencies[dep]) {
packageJson.dependencies[dep] = pkg.dependencies[dep];
console.log(` - Updated ${dep} to ${pkg.dependencies[dep]}`);
} else {
console.log(` - No update for ${dep}`);
}
}
}
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 4)+'\n');
}