mirror of
https://github.com/supabase/supabase.git
synced 2026-09-09 03:19:36 +08:00
## Context Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix all related issues
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
function getFilePaths(folderPath: string, baseFolder = ''): string[] {
|
|
const filepaths: string[] = []
|
|
|
|
const files = fs.readdirSync(folderPath)
|
|
for (const file of files) {
|
|
if (file === '.DS_Store') {
|
|
continue
|
|
}
|
|
|
|
const filePath = path.join(folderPath, file)
|
|
const stats = fs.statSync(filePath)
|
|
|
|
if (stats.isDirectory()) {
|
|
const subFolder = path.join(baseFolder, file)
|
|
const subFolderPaths = getFilePaths(filePath, subFolder)
|
|
filepaths.push(...subFolderPaths)
|
|
} else {
|
|
const filePathRelativeToBase = path.join(baseFolder, file)
|
|
if (file !== '.DS_Store') {
|
|
filepaths.push(filePathRelativeToBase)
|
|
}
|
|
filepaths.push(filePathRelativeToBase)
|
|
}
|
|
}
|
|
|
|
return filepaths
|
|
}
|
|
|
|
export default async function getFileNames(_req: NextApiRequest, res: NextApiResponse) {
|
|
const folderPath = path.join(process.cwd(), 'components/interfaces/Home/Connect/content')
|
|
const filepaths = getFilePaths(folderPath)
|
|
res.statusCode = 200
|
|
res.json(filepaths)
|
|
}
|