Skip to content

Commit 211cb65

Browse files
committed
fix: do not fail on gitignore failures
1 parent 3a3f16e commit 211cb65

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.vscode/settings.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"cSpell.words": [
3-
"astrojs",
4-
"Globified",
5-
"globify"
6-
],
2+
"cSpell.words": ["astrojs", "Globified", "globify"],
73
"explorer.fileNesting.patterns": {
84
"index.js": "*.js"
95
}

src/astro.cts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const astroConfig: Linter.ConfigOverride<Linter.RulesRecord> = {
1212
plugins: ["astro", "only-warn"],
1313
extends: ["plugin:astro/recommended"],
1414
rules: {
15-
...pluginImportAstroRulesExtra
15+
...pluginImportAstroRulesExtra,
1616
},
1717
globals: {
1818
astroHTML: "readonly",

src/typescript.cts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@ import { Linter } from "eslint"
99
const tsFiles = ["**/*.tsx", "**/*.ts", "**/*.mts", "**/*.cts"]
1010
const project = ["**/tsconfig.json", "!**/node_modules/**/tsconfig.json"]
1111

12-
function globifyGitIgnoreFileWithDeps(cwd: string, include: boolean) {
13-
// eslint-disable-next-line @typescript-eslint/no-var-requires
14-
const { globifyGitIgnoreFile } = require("globify-gitignore") as typeof import("globify-gitignore") // prettier-ignore
15-
return globifyGitIgnoreFile(cwd, include)
12+
async function globifyGitIgnoreFileWithDeps(cwd: string, include: boolean) {
13+
try {
14+
// import in the function to allow makeSynchronous to work
15+
/* eslint-disable @typescript-eslint/no-var-requires */
16+
const { globifyGitIgnoreFile } = require("globify-gitignore") as typeof import("globify-gitignore") // prettier-ignore
17+
const { existsSync } = require("fs") as typeof import("fs")
18+
const { join } = require("path") as typeof import("path")
19+
/* eslint-enable @typescript-eslint/no-var-requires */
20+
21+
if (!existsSync(join(cwd, ".gitignore"))) {
22+
return []
23+
}
24+
return await globifyGitIgnoreFile(cwd, include)
25+
} catch (error) {
26+
console.error(error)
27+
return []
28+
}
1629
}
1730
const globifyGitIgnoreFileSync = makeSynchronous(globifyGitIgnoreFileWithDeps) as (
1831
cwd: string,

0 commit comments

Comments
 (0)