mirror of
https://github.com/unraid/api.git
synced 2026-01-28 03:29:14 -06:00
16 lines
569 B
TypeScript
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);
|
|
};
|