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

mongodb-js / devtools-shared / 16048988276

03 Jul 2025 11:17AM UTC coverage: 72.545%. First build
16048988276

Pull #558

github

lerouxb
fallback directoryExists to true, not false
Pull Request #558: fix(ts-autocomplete): fallback directoryExists to true, not false

1502 of 2355 branches covered (63.78%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 1 file covered. (50.0%)

3249 of 4194 relevant lines covered (77.47%)

592.85 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