How to use await-of - 5 common examples

To help you get started, we’ve selected a few await-of examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vmarchaud / servicectl / src / backends / systemd / creators / cluster.ts View on Github external
async removeFiles (service: Service) {
    const repositoryPath = await getRepositoryPath()
    const socketFilename = `servicectl.${service.name}@.socket`
    const serviceFilename = `servicectl.${service.name}@.service`
    const serviceFilepath = path.resolve(repositoryPath, serviceFilename)
    const socketFilepath = path.resolve(repositoryPath, socketFilename)
    // dont handle error, we just want to remove the file, fine if already the case
    let ret = await of(promisify(fs.unlink)(serviceFilepath))
    ret = await of(promisify(fs.unlink)(socketFilepath))
  }
github vmarchaud / servicectl / src / backends / systemd / creators / exec.ts View on Github external
async removeFiles (service: Service) {
    const repositoryPath = await getRepositoryPath()
    const serviceFilename = `servicectl.${service.name}.service`
    const serviceFilepath = path.resolve(repositoryPath, serviceFilename)
    const [ _, err ] = await of(promisify(fs.unlink)(serviceFilepath))
    // dont handle error, we just want to remove the file, fine if already the case
  }
github vmarchaud / servicectl / src / backends / systemd / creators / exec.ts View on Github external
async disable (service: Service, manager: SystemdManager) {
    const serviceFilename = `servicectl.${service.name}.service`
    await of(manager.StopUnit(serviceFilename, StartMode.FAIL))
    await of(manager.DisableUnitFiles([serviceFilename], false))
    await manager.Reload()
  }
}
github vmarchaud / servicectl / src / backends / systemd / creators / exec.ts View on Github external
async disable (service: Service, manager: SystemdManager) {
    const serviceFilename = `servicectl.${service.name}.service`
    await of(manager.StopUnit(serviceFilename, StartMode.FAIL))
    await of(manager.DisableUnitFiles([serviceFilename], false))
    await manager.Reload()
  }
}
github vmarchaud / servicectl / src / backends / systemd / utils / common.ts View on Github external
export const watchFileUpdate = async (path: string, onUpdate: Function): Promise => {
  const [ stat ] = await of(promises.stat(path))
  const state: WatchedFile = {
    offset: stat.size || 0,
    BUFFER_SIZE: 2048
  }
  const cancel = async () => {
    if (state.handle !== undefined) {
      await state.handle.close()
    }
    if (state.watcher !== undefined) {
      state.watcher.close()
    }
  }
  const onFileUpdate = async (type: string) => {
    if (type !== 'change') return

    if (state.handle === undefined) {

await-of

await wrapper for easier errors handling without try-catch

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular await-of functions