@swisseph/node 1.0.3 → 1.0.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swisseph/node",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Swiss Ephemeris for Node.js - high precision astronomical calculations with native bindings",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,7 @@
18
18
  "binding.gyp",
19
19
  "ephemeris",
20
20
  "libswe",
21
+ "scripts",
21
22
  "README.md"
22
23
  ],
23
24
  "keywords": [
@@ -0,0 +1,41 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const sourceDir = path.resolve(__dirname, '../../../native/libswe');
5
+ const targetDir = path.resolve(__dirname, '../libswe');
6
+
7
+ // Function to copy files recursively
8
+ function copyDir(src, dest) {
9
+ if (!fs.existsSync(dest)) {
10
+ fs.mkdirSync(dest, { recursive: true });
11
+ }
12
+
13
+ const entries = fs.readdirSync(src, { withFileTypes: true });
14
+
15
+ for (const entry of entries) {
16
+ const srcPath = path.join(src, entry.name);
17
+ const destPath = path.join(dest, entry.name);
18
+
19
+ if (entry.isDirectory()) {
20
+ copyDir(srcPath, destPath);
21
+ } else {
22
+ fs.copyFileSync(srcPath, destPath);
23
+ }
24
+ }
25
+ }
26
+
27
+ // Main logic
28
+ if (fs.existsSync(sourceDir)) {
29
+ console.log('Development environment detected (native source found).');
30
+ console.log(`Copying libswe files from ${sourceDir} to ${targetDir}...`);
31
+ try {
32
+ copyDir(sourceDir, targetDir);
33
+ console.log('Copy complete.');
34
+ } catch (err) {
35
+ console.error('Error copying files:', err);
36
+ process.exit(1);
37
+ }
38
+ } else {
39
+ console.log('Production environment detected (no native source).');
40
+ console.log('Assuming libswe files are already present in the package.');
41
+ }