Skip to content

Commit c183d33

Browse files
authored
stop roll() from failing if the new cache folder is not created (#243)
* stop roll() from failing if the new cache has no files Today I stumbled upon an error where it would fail when the cache folder was not present ```(typescript) Error: ENOENT: no such file or directory, rename 'REDACTED\node_modules\.cache\rollup-plugin-typescript2/rpt2_759e2fd8d3f20c1a0805faf5404af6bea36632fd/code/cache_' -> 'REDACTED\node_modules\.cache\rollup-plugin-typescript2/rpt2_759e2fd8d3f20c1a0805faf5404af6bea36632fd/code/cache'``` This PR fixes it by checking its existence before trying to rename it * use existsSync instead of fs.existsSync * use renameSync instead of fs.renameSync
1 parent dcf59ac commit c183d33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/rollingcache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ export class RollingCache<DataType> implements ICache<DataType>
9898

9999
this.rolled = true;
100100
removeSync(this.oldCacheRoot);
101-
renameSync(this.newCacheRoot, this.oldCacheRoot);
101+
if (existsSync(this.newCacheRoot)) {
102+
renameSync(this.newCacheRoot, this.oldCacheRoot);
103+
}
102104
}
103105
}

0 commit comments

Comments
 (0)