(filepath: string, search: string | RegExp, replace: string)
| 85 | // Replace last part of the path containing a program to another. If search string not found |
| 86 | // or replacement the same as search string, then null is returned |
| 87 | function replaceProgInPath(filepath: string, search: string | RegExp, replace: string): string { |
| 88 | if (os.platform() === 'win32') { |
| 89 | filepath = filepath.toLowerCase().replace(/\\/g, '/'); |
| 90 | } |
| 91 | const ix = filepath.lastIndexOf('/'); |
| 92 | const prefix = (ix >= 0) ? filepath.substring(0, ix + 1) : '' ; |
| 93 | const suffix = filepath.substring(ix + 1); |
| 94 | const replaced = suffix.replace(search, replace); |
| 95 | if (replaced === suffix) { |
| 96 | return null; |
| 97 | } |
| 98 | const ret = prefix + replaced; |
| 99 | return ret; |
| 100 | } |
| 101 | |
| 102 | const trace = true; |
| 103 |
no outgoing calls
no test coverage detected