-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnode.ts
More file actions
29 lines (27 loc) · 809 Bytes
/
Copy pathnode.ts
File metadata and controls
29 lines (27 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { commitFilesFromBase64 } from "./core.js";
import type {
CommitFilesFromBase64Args,
CommitFilesFromBuffersArgs,
CommitFilesResult,
} from "./interface.ts";
export async function commitFilesFromBuffers({
fileChanges,
...otherArgs
}: CommitFilesFromBuffersArgs): Promise<CommitFilesResult> {
return await commitFilesFromBase64({
...otherArgs,
fileChanges: normalizeFileChanges(fileChanges),
});
}
// Exported for testing only
export function normalizeFileChanges(
fileChanges: CommitFilesFromBuffersArgs["fileChanges"],
): CommitFilesFromBase64Args["fileChanges"] {
return {
additions: fileChanges.additions?.map((a) => ({
path: a.path,
contents: a.contents.toString("base64"),
})),
deletions: fileChanges.deletions?.map((d) => ({ path: d })),
};
}