Files
api/app/core/utils/write-to-boot.ts
Alexis Tyler 855ba2fc75 chore: lint
2021-01-29 12:03:26 +10:30

16 lines
586 B
TypeScript

import fs from 'fs';
import path from 'path';
import prettyBytes from 'pretty-bytes';
import { coreLogger } from '../log';
const writeFile = async (filePath: string, fileContents: string | Buffer) => {
coreLogger.debug(`Writing ${prettyBytes(fileContents.length)} to ${filePath}`);
await fs.promises.writeFile(filePath, fileContents);
};
export const writeToBoot = async (filePath: string, fileContents: string | Buffer) => {
const basePath = '/boot/config/plugins/dynamix/';
const resolvedPath = path.resolve(basePath, filePath);
await writeFile(resolvedPath, fileContents);
};