Typescriptify main.js

This commit is contained in:
Scott Nonnenberg 2021-10-01 11:49:59 -07:00 committed by GitHub
parent e033fd2cf3
commit 9a1430a460
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 721 additions and 524 deletions

View file

@ -7,18 +7,20 @@ import { get, set } from 'lodash';
const ENCODING = 'utf8';
type ConfigType = Record<string, unknown>;
type InternalConfigType = Record<string, unknown>;
export type ConfigType = {
set: (keyPath: string, value: unknown) => void;
get: (keyPath: string) => unknown;
remove: () => void;
};
export function start(
name: string,
targetPath: string,
options?: { allowMalformedOnStartup?: boolean }
): {
set: (keyPath: string, value: unknown) => void;
get: (keyPath: string) => unknown;
remove: () => void;
} {
let cachedValue: ConfigType | undefined;
): ConfigType {
let cachedValue: InternalConfigType | undefined;
try {
const text = readFileSync(targetPath, ENCODING);