()
| 197 | } |
| 198 | |
| 199 | save() { |
| 200 | if (!this.pilePath) return; |
| 201 | if (!fs.existsSync(this.pilePath)) { |
| 202 | fs.mkdirSync(this.pilePath, { recursive: true }); |
| 203 | } |
| 204 | |
| 205 | const sortedIndex = this.sortMap(this.index); |
| 206 | this.index = sortedIndex; |
| 207 | const filePath = path.join(this.pilePath, this.fileName); |
| 208 | const entries = this.index.entries(); |
| 209 | |
| 210 | if (!entries) return; |
| 211 | |
| 212 | let strMap = JSON.stringify(Array.from(entries)); |
| 213 | fs.writeFileSync(filePath, strMap); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | module.exports = new PileIndex(); |
no test coverage detected