Skip to content

Commit 262f35a

Browse files
Fix some NPM compilation problems
1 parent e17fd3a commit 262f35a

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = function (api) {
22
api.cache(true);
33

44
const presets = ["@babel/preset-env", "@babel/preset-typescript"];
5-
const ignore = ["**/__tests__", "**/*.test.ts", "!src/db/**"];
5+
const ignore = ["**/__tests__", "**/*.test.ts", "!src/db/**", "**/util/**"];
66

77
return {
88
presets,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"scripts": {
3030
"clean": "npx rimraf --glob dist/ ./*.tgz",
31-
"copyfiles": "cp ./src/core/db/ ./dist/core/db/ -r",
31+
"copyfiles": "node tools/copyfiles.js",
3232
"test": "vitest",
3333
"test:coverage": "vitest run --coverage",
3434
"babel": "npm run clean && npx babel src -d dist --extensions .ts --no-copy-ignored && npm run copyfiles",

tools/copyfiles.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const { execSync } = require('child_process');
2+
const os = require('os');
3+
const path = require('path');
4+
5+
function runCommand(command) {
6+
try {
7+
const result = execSync(command, { stdio: 'pipe' });
8+
if (result)
9+
console.log(result.toString());
10+
} catch (error) {
11+
console.error('Error executing command:', error);
12+
process.exit(1);
13+
}
14+
}
15+
16+
function copyFilesWindows() {
17+
console.log('Copying files for Windows...');
18+
19+
runCommand('mkdir dist\\core\\src\\db');
20+
21+
runCommand('xcopy .\\src\\core\\src\\db\\ .\\dist\\core\\src\\db\\ /s /e');
22+
23+
console.log('Files copied successfully for Windows.');
24+
}
25+
26+
function copyFilesLinux() {
27+
console.log('Copying files for Linux...');
28+
29+
runCommand('mkdir -p dist/core/src/db');
30+
31+
runCommand('cp -r ./src/core/src/db/* ./dist/core/src/db');
32+
33+
console.log('Files copied successfully for Linux.');
34+
}
35+
36+
function copyFilesMac() {
37+
console.log('Copying files for macOS...');
38+
39+
runCommand('mkdir -p dist/core/src/db');
40+
41+
runCommand('cp -r ./src/core/src/db/* ./dist/core/src/db');
42+
43+
console.log('Files copied successfully for macOS.');
44+
}
45+
46+
function copyFiles() {
47+
const platform = os.type();
48+
49+
switch (platform) {
50+
case 'Linux':
51+
copyFilesLinux();
52+
break;
53+
case 'Darwin':
54+
copyFilesMac();
55+
break;
56+
case 'Windows_NT':
57+
copyFilesWindows();
58+
break;
59+
default:
60+
console.error('Unsupported OS found: ' + platform);
61+
process.exit(1);
62+
}
63+
}
64+
65+
copyFiles();

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"module": "CommonJS",
1010
"outDir": "./dist",
1111
"strict": true,
12-
"skipLibCheck": true
12+
"skipLibCheck": true,
13+
"resolveJsonModule": true
1314
},
1415
"include": [
1516
"src"
@@ -18,6 +19,7 @@
1819
"node_modules",
1920
"**/__tests__",
2021
"**/*.test.ts",
21-
"**/vitest.config.*"
22+
"**/vitest.config.*",
23+
"**/util/**"
2224
]
2325
}

0 commit comments

Comments
 (0)