• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / devtools-shared / 14664746835

25 Apr 2025 12:36PM CUT coverage: 72.362% (-0.03%) from 72.39%
14664746835

push

github

mongodb-devtools-bot[bot]
chore(ci): bump packages

1460 of 2285 branches covered (63.89%)

Branch coverage included in aggregate %.

3093 of 4007 relevant lines covered (77.19%)

636.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.05
/packages/monorepo-tools/src/utils/update-package-json.ts
1
import path from 'path';
1✔
2
import { promises as fs } from 'fs';
1✔
3

4
export const skip = Symbol('skip');
1✔
5

6
type MaybePromise<T> = T | PromiseLike<T>;
7
export type UpdatePackageJsonFunction = (
8
  pkgJson: Record<string, any>,
9
  s: typeof skip,
10
) => MaybePromise<typeof skip | Record<string, any>>;
11

12
export async function updatePackageJson(
1✔
13
  packageDir: string,
14
  updateFn: UpdatePackageJsonFunction,
15
): Promise<void> {
16
  const pathToPkg = path.resolve(packageDir, 'package.json');
×
17
  // eslint-disable-next-line @typescript-eslint/no-var-requires
18
  const pkgJson = require(pathToPkg);
×
19
  const updated = await updateFn(pkgJson, skip);
×
20

21
  if (updated === skip) {
×
22
    return;
×
23
  }
24

25
  if (!updated || typeof updated !== 'object') {
×
26
    const updatedStr = JSON.stringify(updated);
×
27
    throw new Error(
×
28
      `updatePackageJson updateFn should return a package.json object, got ${updatedStr}`,
29
    );
30
  }
31

32
  await fs.writeFile(
×
33
    pathToPkg,
34
    JSON.stringify(updated, null, 2).trim() + '\n',
35
    'utf8',
36
  );
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc