()
| 79 | return undefined; |
| 80 | }, |
| 81 | options() { |
| 82 | const userInput = this.userInput; |
| 83 | if (userInput === '') { |
| 84 | return []; |
| 85 | } |
| 86 | |
| 87 | try { |
| 88 | let searchPath: string; |
| 89 | |
| 90 | if (!existsSync(userInput)) { |
| 91 | searchPath = dirname(userInput); |
| 92 | } else { |
| 93 | const stat = lstatSync(userInput); |
| 94 | if (stat.isDirectory() && (!opts.directory || userInput.endsWith('/'))) { |
| 95 | searchPath = userInput; |
| 96 | } else { |
| 97 | searchPath = dirname(userInput); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // Strip trailing slash so startsWith matches the directory itself among its siblings |
| 102 | const prefix = |
| 103 | userInput.length > 1 && userInput.endsWith('/') ? userInput.slice(0, -1) : userInput; |
| 104 | |
| 105 | const items = readdirSync(searchPath) |
| 106 | .map((item) => { |
| 107 | const path = join(searchPath, item); |
| 108 | const stats = lstatSync(path); |
| 109 | return { |
| 110 | name: item, |
| 111 | path, |
| 112 | isDirectory: stats.isDirectory(), |
| 113 | }; |
| 114 | }) |
| 115 | .filter( |
| 116 | ({ path, isDirectory }) => path.startsWith(prefix) && (isDirectory || !opts.directory) |
| 117 | ); |
| 118 | |
| 119 | return items.map((item) => ({ |
| 120 | value: item.path, |
| 121 | })); |
| 122 | } catch (_e) { |
| 123 | return []; |
| 124 | } |
| 125 | }, |
| 126 | }); |
| 127 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected