(cwd, pattern)
| 1091 | } |
| 1092 | |
| 1093 | function ensureGitignoreLine(cwd, pattern) { |
| 1094 | const gitignorePath = path.join(cwd, '.gitignore') |
| 1095 | let content = '' |
| 1096 | try { |
| 1097 | if (fs.existsSync(gitignorePath)) { |
| 1098 | content = fs.readFileSync(gitignorePath, 'utf8') |
| 1099 | } |
| 1100 | } catch { |
| 1101 | return |
| 1102 | } |
| 1103 | if (content.includes(pattern)) return |
| 1104 | const next = content.length === 0 || content.endsWith('\n') ? content : `${content}\n` |
| 1105 | try { |
| 1106 | fs.writeFileSync(gitignorePath, `${next}${pattern}\n`) |
| 1107 | } catch { |
| 1108 | // ignore write errors |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | function ensurePasteDirectory(cwd) { |
| 1113 | const dirPath = path.join(cwd, PASTE_IMAGE_DIR) |
no outgoing calls
no test coverage detected