UNPKG

@oclif/plugin-update

Version:

[![Version](https://img.shields.io/npm/v/@oclif/plugin-update.svg)](https://npmjs.org/package/@oclif/plugin-update) [![Downloads/week](https://img.shields.io/npm/dw/@oclif/plugin-update.svg)](https://npmjs.org/package/@oclif/plugin-update) [![License](htt

23 lines (22 loc) 648 B
import { readdir, stat, utimes, writeFile } from 'node:fs/promises'; import { join } from 'node:path'; export async function touch(p) { try { await utimes(p, new Date(), new Date()); } catch { await writeFile(p, ''); } } export async function ls(dir) { const files = await readdir(dir); const paths = files.map((f) => join(dir, f)); return Promise.all(paths.map((path) => stat(path).then((s) => ({ path, stat: s })))); } export function wait(ms, unref = false) { return new Promise((resolve) => { const t = setTimeout(() => resolve(), ms); if (unref) t.unref(); }); }