(
gitDir: string,
files: Record<string, string>,
options: {
stage?: string[] | true;
commitMessage?: string;
} = {}
)
| 135 | }; |
| 136 | |
| 137 | export const prepareRepo = async ( |
| 138 | gitDir: string, |
| 139 | files: Record<string, string>, |
| 140 | options: { |
| 141 | stage?: string[] | true; |
| 142 | commitMessage?: string; |
| 143 | } = {} |
| 144 | ): Promise<void> => { |
| 145 | for (const [relativePath, content] of Object.entries(files)) { |
| 146 | writeRepoFile(gitDir, relativePath, content); |
| 147 | } |
| 148 | |
| 149 | const stageFiles = |
| 150 | options.stage === true |
| 151 | ? Object.keys(files) |
| 152 | : Array.isArray(options.stage) |
| 153 | ? options.stage |
| 154 | : options.commitMessage |
| 155 | ? Object.keys(files) |
| 156 | : []; |
| 157 | |
| 158 | if (stageFiles.length > 0) { |
| 159 | await runGit(['add', ...stageFiles], gitDir); |
| 160 | } |
| 161 | |
| 162 | if (options.commitMessage) { |
| 163 | await runGit(['commit', '-m', options.commitMessage], gitDir); |
| 164 | } |
| 165 | }; |
| 166 | |
| 167 | export const writeRepoFile = ( |
| 168 | gitDir: string, |
no test coverage detected
searching dependent graphs…