Skip to content

Commit

Permalink
fix: do not fail on gitignore failures
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 15, 2024
1 parent 3a3f16e commit 211cb65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"cSpell.words": [
"astrojs",
"Globified",
"globify"
],
"cSpell.words": ["astrojs", "Globified", "globify"],
"explorer.fileNesting.patterns": {
"index.js": "*.js"
}
Expand Down
2 changes: 1 addition & 1 deletion src/astro.cts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const astroConfig: Linter.ConfigOverride<Linter.RulesRecord> = {
plugins: ["astro", "only-warn"],
extends: ["plugin:astro/recommended"],
rules: {
...pluginImportAstroRulesExtra
...pluginImportAstroRulesExtra,
},
globals: {
astroHTML: "readonly",
Expand Down
21 changes: 17 additions & 4 deletions src/typescript.cts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ import { Linter } from "eslint"
const tsFiles = ["**/*.tsx", "**/*.ts", "**/*.mts", "**/*.cts"]
const project = ["**/tsconfig.json", "!**/node_modules/**/tsconfig.json"]

function globifyGitIgnoreFileWithDeps(cwd: string, include: boolean) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { globifyGitIgnoreFile } = require("globify-gitignore") as typeof import("globify-gitignore") // prettier-ignore
return globifyGitIgnoreFile(cwd, include)
async function globifyGitIgnoreFileWithDeps(cwd: string, include: boolean) {
try {
// import in the function to allow makeSynchronous to work
/* eslint-disable @typescript-eslint/no-var-requires */
const { globifyGitIgnoreFile } = require("globify-gitignore") as typeof import("globify-gitignore") // prettier-ignore
const { existsSync } = require("fs") as typeof import("fs")
const { join } = require("path") as typeof import("path")
/* eslint-enable @typescript-eslint/no-var-requires */

if (!existsSync(join(cwd, ".gitignore"))) {
return []
}
return await globifyGitIgnoreFile(cwd, include)
} catch (error) {
console.error(error)
return []
}
}
const globifyGitIgnoreFileSync = makeSynchronous(globifyGitIgnoreFileWithDeps) as (
cwd: string,
Expand Down

0 comments on commit 211cb65

Please sign in to comment.