(fileName: string = "")
| 54 | } |
| 55 | |
| 56 | toAbsolutePath(fileName: string = "") { |
| 57 | const topAbsolutePath = this.topPath; |
| 58 | |
| 59 | let finalPath = ""; |
| 60 | if (path.normalize(fileName).indexOf(topAbsolutePath) === 0) { |
| 61 | finalPath = fileName; |
| 62 | } else if (os.platform() === "win32") { |
| 63 | const reg = new RegExp("^[A-Za-z]{1}:[\\\\/]{1}"); |
| 64 | if (reg.test(this.cwd)) { |
| 65 | finalPath = path.normalize(path.join(this.cwd, fileName)); |
| 66 | } else if (reg.test(fileName)) { |
| 67 | finalPath = path.normalize(fileName); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | if (!finalPath) { |
| 72 | finalPath = path.normalize(path.join(this.topPath, this.cwd, fileName)); |
| 73 | } |
| 74 | |
| 75 | if (this.isOutsideWorkspace(finalPath)) throw new Error(ERROR_MSG_01); |
| 76 | return finalPath; |
| 77 | } |
| 78 | |
| 79 | checkPath(fileNameOrPath: string) { |
| 80 | if (this.isRootTopRath()) return true; |
no test coverage detected