Debian Codegraph @

fs2/unlink-sync.js

raw
1 "use strict";
2
3 const ensureString = require("type/string/ensure")
4 , isObject = require("type/object/is")
5 , path = require("path")
6 , fs = require("fs");
7
8 module.exports = (filename, options = {}) => {
9 filename = path.resolve(ensureString(filename));
10 if (!isObject(options)) options = {};
11 try {
12 fs.unlinkSync(filename);
13 } catch (error) {
14 if (error.code === "ENOENT" && options.loose) return;
15 throw error;
16 }
17 };