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

Function writeFile

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

Source from the content-addressed store, hash-verified

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

Callers 3

persistEntryMethod · 0.70
persistMediaMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected