-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathfs.ts
More file actions
31 lines (29 loc) · 795 Bytes
/
fs.ts
File metadata and controls
31 lines (29 loc) · 795 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
30
31
import { promises as fs } from "fs";
import * as path from "path";
import type { FileAddition } from "./github/graphql/generated/types.js";
import { commitFilesFromBuffers } from "./node.js";
import {
CommitFilesFromDirectoryArgs,
CommitFilesResult,
} from "./interface.js";
export const commitFilesFromDirectory = async ({
cwd,
fileChanges,
...otherArgs
}: CommitFilesFromDirectoryArgs): Promise<CommitFilesResult> => {
const additions: FileAddition[] = await Promise.all(
(fileChanges.additions || []).map(async (p) => {
return {
path: p,
contents: await fs.readFile(path.join(cwd, p)),
};
}),
);
return commitFilesFromBuffers({
...otherArgs,
fileChanges: {
additions,
deletions: fileChanges.deletions,
},
});
};