| 2 | import path from 'path'; |
| 3 | |
| 4 | export async function getAvailablePipes() { |
| 5 | // Construct the path containing all pipes folders. |
| 6 | const pipesPath = path.join(process.cwd(), 'baseai', 'pipes'); |
| 7 | |
| 8 | // Check if the baseai directory exists. |
| 9 | if (!fs.existsSync(pipesPath)) return []; |
| 10 | |
| 11 | // Get all directories names in the pipe path. |
| 12 | const pipeNames = await fs.promises.readdir(pipesPath); |
| 13 | |
| 14 | // Make complete paths for each pipe. |
| 15 | const slugifiedPipes = pipeNames.map(pipeName => |
| 16 | pipeName.replace('.ts', '') |
| 17 | ); |
| 18 | |
| 19 | // Return the pipe names. |
| 20 | return slugifiedPipes; |
| 21 | } |