@oclif/plugin-update
Version:
[](https://npmjs.org/package/@oclif/plugin-update) [](https://npmjs.org/package/@oclif/plugin-update) [ • 648 B
JavaScript
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();
});
}