feat: git add multiple files at once
This commit is contained in:
10
src/git.ts
10
src/git.ts
@@ -60,7 +60,15 @@ class Git {
|
|||||||
config = (prop: string, value: string) =>
|
config = (prop: string, value: string) =>
|
||||||
this.exec(`config ${prop} "${value}"`);
|
this.exec(`config ${prop} "${value}"`);
|
||||||
|
|
||||||
add = (file: string) => this.exec(`add ${file}`);
|
add = (file: string | string[]) => {
|
||||||
|
let str = '';
|
||||||
|
if (Array.isArray(file)) {
|
||||||
|
file.map((f) => (str += ` ${f}`));
|
||||||
|
} else {
|
||||||
|
str = file;
|
||||||
|
}
|
||||||
|
return this.exec(`add ${str}`);
|
||||||
|
};
|
||||||
|
|
||||||
commit = (message: string) => this.exec(`commit -m "${message}"`);
|
commit = (message: string) => this.exec(`commit -m "${message}"`);
|
||||||
|
|
||||||
|
@@ -129,12 +129,10 @@ export async function pushNewFiles(files: File[] = []): Promise<any> {
|
|||||||
await git.pull();
|
await git.pull();
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
files.map(async ({ filename, data }) => {
|
files.map(({ filename, data }) => fsp.writeFile(filename, data))
|
||||||
await fsp.writeFile(filename, data);
|
|
||||||
await git.add(filename);
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await git.add(files.map(({ filename }) => filename));
|
||||||
await git.commit(`chore(updates): updated entries in files`);
|
await git.commit(`chore(updates): updated entries in files`);
|
||||||
await git.push();
|
await git.push();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user