0.0.0-3 • Published 3 months ago

@vltpkg/rollback-remove v0.0.0-3

Weekly downloads
-
License
BSD-2-Clause-Pate...
Repository
github
Last release
3 months ago

rollback-remove

@vltpkg/rollback-remove

A utility for removing stuff, in such a way that the removal can be rolled back on failure, or confirmed and executed in a detached background process.

Usage

The best way to use this is to not catch errors, but detect failure in a finally block and either confirm or roll back appropriately.

import { RollbackRemove } from '@vltpkg/rollback-remove'

const remover = new RollbackRemove()

let success = false
try {
  await remover.rm('some/path')
  doSomethingThatMayThrow()
  remover.confirm()
  success = true
} finally {
  if (!success) await remover.rollback()
}
0.0.0-3

3 months ago

0.0.0-2

3 months ago