mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
30 lines
780 B
JavaScript
Executable File
30 lines
780 B
JavaScript
Executable File
import fs from "node:fs"
|
|
import path from "node:path"
|
|
|
|
import Vars from "../vars"
|
|
|
|
export default async () => {
|
|
const finalServices = []
|
|
|
|
let services = fs.readdirSync(Vars.servicesPath)
|
|
|
|
for await (let _path of services) {
|
|
_path = path.resolve(Vars.servicesPath, _path)
|
|
|
|
if (fs.lstatSync(_path).isDirectory()) {
|
|
// search main file "*.service.*" (using regex) on the root of the service path
|
|
const mainFile = fs.readdirSync(_path).find((filename) => {
|
|
const regex = new RegExp(`^.*\.service\..*$`)
|
|
|
|
return regex.test(filename)
|
|
})
|
|
|
|
if (mainFile) {
|
|
finalServices.push(path.resolve(_path, mainFile))
|
|
}
|
|
}
|
|
}
|
|
|
|
return finalServices
|
|
}
|