Files
api/app/core/utils/write-to-boot.ts
2020-11-11 16:13:30 +10:30

16 lines
569 B
TypeScript

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