| 1 | import fs from "fs"; |
| 2 | import { IDE } from ".."; |
| 3 | import { getGlobalContinueIgnorePath } from "../util/paths"; |
| 4 | import { gitIgArrayFromFile } from "./ignore"; |
| 5 | |
| 6 | export const getGlobalContinueIgArray = () => { |
| 7 | const contents = fs.readFileSync(getGlobalContinueIgnorePath(), "utf8"); |
| 8 | return gitIgArrayFromFile(contents); |
| 9 | }; |
| 10 | |
| 11 | export const getWorkspaceContinueIgArray = async (ide: IDE) => { |
| 12 | const dirs = await ide.getWorkspaceDirs(); |
| 13 | return await dirs.reduce( |
| 14 | async (accPromise, dir) => { |
| 15 | const acc = await accPromise; |
| 16 | try { |
| 17 | const contents = await ide.readFile(`${dir}/.continueignore`); |
| 18 | return [...acc, ...gitIgArrayFromFile(contents)]; |
| 19 | } catch (err) { |
| 20 | console.error(err); |
| 21 | return acc; |
| 22 | } |
| 23 | }, |
| 24 | Promise.resolve([] as string[]), |
| 25 | ); |
| 26 | }; |