Skip to content

Commit f3b5944

Browse files
committed
chore: file exists
1 parent 9dbf579 commit f3b5944

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scripts/utils.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import nodePath from 'node:path';
33

44
export function assign(obj = {}, lang = '', key = '', value = '') {
55
// Only add key if value exists
6-
if (!value || value.startsWith('//')) return;
6+
if (!value) return;
77
obj[lang] ??= {}; // Does lang exist?
88
obj[lang][key] = value;
99
}
@@ -13,6 +13,15 @@ export async function readJSON(file) {
1313
return JSON.parse(content);
1414
}
1515

16+
export async function fileExists(path) {
17+
try {
18+
await fs.access(path);
19+
return true;
20+
} catch {
21+
return false;
22+
}
23+
}
24+
1625
export function writeFile(path, data) {
1726
return fs.writeFile(path, data);
1827
}

0 commit comments

Comments
 (0)