rads-db 0.1.101 → 0.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,6 +43,13 @@ var _default = {
|
|
|
43
43
|
});
|
|
44
44
|
if (result?.text) data = result.text;
|
|
45
45
|
}
|
|
46
|
+
const dirname = _nodePath.default.dirname(filepath);
|
|
47
|
+
const isExistingDir = await dirExists(dirname);
|
|
48
|
+
if (!isExistingDir) {
|
|
49
|
+
await _promises.default.mkdir(dirname, {
|
|
50
|
+
recursive: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
46
53
|
await _promises.default.writeFile(filepath, data, options);
|
|
47
54
|
return result;
|
|
48
55
|
},
|
|
@@ -71,6 +78,14 @@ var _default = {
|
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
80
|
module.exports = _default;
|
|
81
|
+
async function dirExists(path2) {
|
|
82
|
+
try {
|
|
83
|
+
await _promises.default.access(path2);
|
|
84
|
+
return true;
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
74
89
|
function sanitizeFilepath(filepath) {
|
|
75
90
|
const result = _nodePath.default.resolve(filepath);
|
|
76
91
|
if (!result.startsWith(root)) throw new Error("Invalid path");
|
|
@@ -35,6 +35,11 @@ export default {
|
|
|
35
35
|
if (result?.text)
|
|
36
36
|
data = result.text;
|
|
37
37
|
}
|
|
38
|
+
const dirname = path.dirname(filepath);
|
|
39
|
+
const isExistingDir = await dirExists(dirname);
|
|
40
|
+
if (!isExistingDir) {
|
|
41
|
+
await fs.mkdir(dirname, { recursive: true });
|
|
42
|
+
}
|
|
38
43
|
await fs.writeFile(filepath, data, options);
|
|
39
44
|
return result;
|
|
40
45
|
},
|
|
@@ -64,6 +69,14 @@ export default {
|
|
|
64
69
|
return await fs.unlink(filepath);
|
|
65
70
|
}
|
|
66
71
|
};
|
|
72
|
+
async function dirExists(path2) {
|
|
73
|
+
try {
|
|
74
|
+
await fs.access(path2);
|
|
75
|
+
return true;
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
67
80
|
function sanitizeFilepath(filepath) {
|
|
68
81
|
const result = path.resolve(filepath);
|
|
69
82
|
if (!result.startsWith(root))
|