(k: string, v: any)
| 1369 | constructor(public path: string) {} |
| 1370 | |
| 1371 | set(k: string, v: any) { |
| 1372 | const data = (this.readAll() || '').toString("utf8"); |
| 1373 | const lines = data.split(/\n/); |
| 1374 | |
| 1375 | let found = false; |
| 1376 | for (let i = 0; i < lines.length; i++) { |
| 1377 | const trimmed = lines[i].trim(); |
| 1378 | if (trimmed.indexOf(k + '=') == 0) { |
| 1379 | lines[i] = k + '=' + v; |
| 1380 | found = true; |
| 1381 | } |
| 1382 | } |
| 1383 | if (!found) { |
| 1384 | lines.push(k + "=" + v); |
| 1385 | } |
| 1386 | const newdata = lines.join('\n') + '\n'; |
| 1387 | writeFile(this.path, newdata, 'utf8'); |
| 1388 | } |
| 1389 | |
| 1390 | private readAll() { |
| 1391 | if (exists(this.path)) { |
no test coverage detected