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

nodeplusplus / xregex-logger / 78

pending completion
78

Pull #12

circleci

Unknown Committer
Unknown Commit Message
Pull Request #12: Bump json5 from 2.1.3 to 2.2.3

22 of 22 branches covered (100.0%)

Branch coverage included in aggregate %.

52 of 52 relevant lines covered (100.0%)

2.94 hits per line

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

100.0
/src/createFile.ts
1
import fs from "fs";
2✔
2
import path from "path";
2✔
3
import pino from "pino";
2✔
4
import { nanoid } from "nanoid";
2✔
5

6
import { ILoggerCreator, ILoggerCreatorOpts } from "./types";
7
import { loggerOpts, ILoggerOptions } from "./constants";
2✔
8

9
export const createFile: ILoggerCreator = function createSilent(
2✔
10
  opts?: ILoggerCreatorOpts
11
) {
12
  const options: ILoggerOptions = {
3✔
13
    ...opts,
14
    ...loggerOpts,
15
  };
16
  if (!options.name) options.name = nanoid();
3✔
17

18
  const logFilePath = resolveLogPath(options.name, opts?.destination);
3✔
19
  const dest = pino.destination(logFilePath);
3✔
20

21
  return pino(options, dest);
3✔
22
};
23

24
function resolveLogPath(name: string, destination?: string) {
25
  const logFilePath = path.resolve(destination || "logs", `${name}.log`);
3✔
26

27
  const logDirPath = path.dirname(logFilePath);
3✔
28
  if (!fs.existsSync(logDirPath)) fs.mkdirSync(logDirPath, { recursive: true });
3✔
29

30
  return logFilePath;
3✔
31
}
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