* `rootPath` is a HAPI-managed directory only when it lives under * `configuration.happyHomeDir` (the default `OPENCODE_CONFIG_DIR` we * synthesize per-session). If a user has exported `OPENCODE_CONFIG_DIR` * pointing at e.g. their own `~/.config/opencode`, we must not pollute it * with a placeh
(rootPath: string)
| 131 | * with a placeholder `package.json`. |
| 132 | */ |
| 133 | function isHapiManagedDir(rootPath: string): boolean { |
| 134 | const home = configuration.happyHomeDir; |
| 135 | if (!home) { |
| 136 | return false; |
| 137 | } |
| 138 | const rel = relative(home, rootPath); |
| 139 | // `relative` returns a path that does NOT start with '..' and is not |
| 140 | // absolute when rootPath is inside home. On Windows a cross-volume |
| 141 | // input (e.g. home=`C:\\hapi`, rootPath=`D:\\…`) makes `relative` |
| 142 | // return the absolute `D:\\…` verbatim — `startsWith('/')` would miss |
| 143 | // that, so use `isAbsolute` which covers both POSIX `/` and win32 |
| 144 | // `<letter>:\\`. |
| 145 | return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel); |
| 146 | } |
| 147 | |
| 148 | function hasDeclaredPluginPackage(packageJsonPath: string): boolean { |
| 149 | try { |
no outgoing calls
no test coverage detected