mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
feat: Add the merge to the file. (#2643)
* feat: Add the merge to the file. * chore: Fix the early escape
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as matches from "ts-matches"
|
||||
import * as YAML from "yaml"
|
||||
import * as TOML from "@iarna/toml"
|
||||
import _ from "lodash"
|
||||
import * as T from "../types"
|
||||
import * as fs from "fs"
|
||||
|
||||
@@ -82,6 +83,12 @@ export class FileHelper<A> {
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
async merge(data: A, effects: T.Effects) {
|
||||
const fileData = (await this.read(effects).catch(() => ({}))) || {}
|
||||
const mergeData = _.merge({}, fileData, data)
|
||||
return await this.write(mergeData, effects)
|
||||
}
|
||||
/**
|
||||
* Create a File Helper for an arbitrary file type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user