UNPKG

@cocalc/backend

Version:

CoCalc backend functionality: functionality used by either the hub, the next.js server or the project.

30 lines 892 B
"use strict"; /* * This file is part of CoCalc: Copyright © 2023 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ Object.defineProperty(exports, "__esModule", { value: true }); exports.touch = void 0; const promises_1 = require("node:fs/promises"); // touch the file in a similar manner as "touch" in linux async function touch(path, createIfMissing = true) { try { const now = new Date(); await (0, promises_1.utimes)(path, now, now); return true; } catch (err) { try { if (createIfMissing && "ENOENT" === err.code) { const fd = await (0, promises_1.open)(path, "a"); await fd.close(); return true; } } finally { return false; } } } exports.touch = touch; //# sourceMappingURL=touch.js.map