(folderPath: string)
| 168 | } |
| 169 | |
| 170 | folderIsRestrict(folderPath: string) { |
| 171 | const absolutePath = path.resolve(folderPath) |
| 172 | |
| 173 | // if folder is not a Laravel project, it is restricted |
| 174 | if(!this.isLaravelProject(folderPath)) { |
| 175 | console.log("Folder is not a Laravel project: ", folderPath, absolutePath) |
| 176 | return true |
| 177 | } |
| 178 | |
| 179 | console.log("Checking if folder is valid: ", folderPath, absolutePath) |
| 180 | |
| 181 | const invalidPaths = [ |
| 182 | "/", "C:\\", "/bin", "/etc", "/usr", "C:\\Windows", "C:\\Program Files" |
| 183 | ].map(p => path.resolve(p)) |
| 184 | |
| 185 | // Check if the projectPath is exactly one of the invalid paths or a subdirectory of them |
| 186 | return !absolutePath || invalidPaths.some( |
| 187 | invalidPath => absolutePath === invalidPath || absolutePath.startsWith(`${invalidPath}${path.sep}`) |
| 188 | ) |
| 189 | } |
| 190 | |
| 191 | isLaravelProject(folderPath: string) { |
| 192 | return this.fileExists(path.join(folderPath, 'artisan')) |
no test coverage detected