Skip to content

Commit f6acfb1

Browse files
isabellahochstainless-app[bot]
authored andcommitted
minor linting fixes (#9)
* create helpers * export helpers * update deps * fix typing errors in helpers * linting fixes
1 parent 09dc65a commit f6acfb1

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/lib/helpers.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import { glob } from 'glob';
43
import minimatch from 'minimatch';
4+
import pkg from 'glob';
5+
const { glob } = pkg;
56

67
export interface FileData {
78
path: string;
89
contents: string;
910
}
1011

1112
const DEFAULT_PATTERNS = [
12-
'**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx',
13-
'**/package.json', '**/tsconfig*.json', '**/*.config.*'
13+
'**/*.ts',
14+
'**/*.tsx',
15+
'**/*.js',
16+
'**/*.jsx',
17+
'**/package.json',
18+
'**/tsconfig*.json',
19+
'**/*.config.*',
1420
];
1521

1622
const DEFAULT_IGNORE = [
@@ -22,28 +28,28 @@ const DEFAULT_IGNORE = [
2228
'.next/**',
2329
'coverage/**',
2430
'**/__tests__/**',
25-
'**/.env*'
31+
'**/.env*',
2632
];
2733

2834
export async function collectFiles(
2935
basePath: string = process.cwd(),
3036
patterns: string[] = DEFAULT_PATTERNS,
31-
ignore: string[] = DEFAULT_IGNORE
37+
ignore: string[] = DEFAULT_IGNORE,
3238
): Promise<FileData[]> {
3339
const originalCwd = process.cwd();
34-
40+
3541
try {
3642
process.chdir(basePath);
37-
43+
3844
const allFilePaths: string[] = [];
3945
for (const pattern of patterns) {
4046
const globResult = glob.sync(pattern, { nodir: true });
41-
const filtered = globResult.filter((match: string) =>
42-
!ignore.some(ignorePattern => minimatch(match, ignorePattern))
47+
const filtered = globResult.filter(
48+
(match: string) => !ignore.some((ignorePattern) => minimatch(match, ignorePattern)),
4349
);
4450
allFilePaths.push(...filtered);
4551
}
46-
52+
4753
const filePaths = [...new Set(allFilePaths)];
4854

4955
const files: FileData[] = [];
@@ -52,9 +58,9 @@ export async function collectFiles(
5258
try {
5359
const contents = fs.readFileSync(path.resolve(basePath, filePath), 'utf8');
5460
if (contents.trim()) {
55-
files.push({
56-
path: filePath,
57-
contents
61+
files.push({
62+
path: filePath,
63+
contents,
5864
});
5965
}
6066
} catch {
@@ -68,19 +74,16 @@ export async function collectFiles(
6874
}
6975
}
7076

71-
export function applyChanges(
72-
changedFiles: FileData[],
73-
basePath: string = process.cwd()
74-
): void {
77+
export function applyChanges(changedFiles: FileData[], basePath: string = process.cwd()): void {
7578
for (const file of changedFiles) {
7679
try {
7780
const fullPath = path.resolve(basePath, file.path);
7881
const dirPath = path.dirname(fullPath);
79-
82+
8083
fs.mkdirSync(dirPath, { recursive: true });
8184
fs.writeFileSync(fullPath, file.contents, 'utf8');
8285
} catch {
8386
continue;
8487
}
8588
}
86-
}
89+
}

0 commit comments

Comments
 (0)