Skip to content

Commit 770fb34

Browse files
committed
allow local cmd/perm loading on dev
1 parent 36ff10a commit 770fb34

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
data/
1314

1415
# debug
1516
npm-debug.log*

lib/cloudflare.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ const MODULES = [
2121
async function getData<T>(
2222
type: 'commands' | 'permissions',
2323
): Promise<Record<string, T>> {
24+
if (process.env.NODE_ENV === 'development') {
25+
// In development, return local data from the data folder
26+
const data = {} as Record<string, T>;
27+
for (const mod of MODULES) {
28+
const fileName = `EssentialsX${mod.replace(' ', '')}-${type}.json`;
29+
// eslint-disable-next-line @typescript-eslint/no-require-imports
30+
data[mod.length ? mod : 'Essentials'] = require(`@/data/${fileName}`);
31+
}
32+
33+
return data;
34+
}
35+
2436
const bucket = await getR2Bucket();
2537
if (!bucket) {
2638
throw new Error('R2 bucket not found');

0 commit comments

Comments
 (0)