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