MCPcopy Create free account
hub / github.com/decaporg/decap-cms / writeFile

Function writeFile

packages/decap-cms-backend-test/src/implementation.ts:71–80  ·  view source on GitHub ↗
(path: string, content: string | AssetProxy, tree: RepoTree)

Source from the content-addressed store, hash-verified

69}
70
71function writeFile(path: string, content: string | AssetProxy, tree: RepoTree) {
72 const segments = path.split('/');
73 let obj = tree;
74 while (segments.length > 1) {
75 const segment = segments.shift() as string;
76 obj[segment] = obj[segment] || {};
77 obj = obj[segment] as RepoTree;
78 }
79 (obj[segments.shift() as string] as RepoFile) = { content, path };
80}
81
82function deleteFile(path: string, tree: RepoTree) {
83 unset(tree, path.split('/'));

Callers 4

moveFileFunction · 0.70
persistEntryMethod · 0.70
persistMediaMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected