@dbcube/core 1.0.36 → 1.0.38
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/dist/index.cjs +24 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -700,36 +700,38 @@ import * as fs3 from "fs";
|
|
|
700
700
|
import { promisify } from "util";
|
|
701
701
|
var execAsync = promisify(exec);
|
|
702
702
|
var SqliteExecutor = class {
|
|
703
|
-
binaryPath
|
|
703
|
+
binaryPath;
|
|
704
704
|
dbPath;
|
|
705
705
|
constructor(dbPath) {
|
|
706
706
|
this.dbPath = dbPath;
|
|
707
|
+
this.binaryPath = this.getBinaryPath();
|
|
707
708
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
709
|
+
getBinaryPath() {
|
|
710
|
+
const possibleDirs = [
|
|
711
|
+
path4.resolve(process.cwd(), ".dbcube", "bin"),
|
|
712
|
+
path4.resolve(process.cwd(), "node_modules", ".dbcube", "bin"),
|
|
713
|
+
path4.resolve(__dirname, "..", "bin")
|
|
714
|
+
];
|
|
715
|
+
const platform2 = process.platform;
|
|
716
|
+
const extension = platform2 === "win32" ? ".exe" : "";
|
|
717
|
+
const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
|
|
718
|
+
for (const dir of possibleDirs) {
|
|
719
|
+
const fullPath = path4.join(dir, binaryName);
|
|
720
|
+
if (fs3.existsSync(fullPath)) {
|
|
721
|
+
return fullPath;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const fallbackName = `sqlite-engine${extension}`;
|
|
725
|
+
for (const dir of possibleDirs) {
|
|
726
|
+
const fullPath = path4.join(dir, fallbackName);
|
|
727
|
+
if (fs3.existsSync(fullPath)) {
|
|
728
|
+
return fullPath;
|
|
722
729
|
}
|
|
723
|
-
const platform2 = process.platform;
|
|
724
|
-
const extension = platform2 === "win32" ? ".exe" : "";
|
|
725
|
-
const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
|
|
726
|
-
this.binaryPath = path4.join(binDir, binaryName);
|
|
727
730
|
}
|
|
728
|
-
return
|
|
731
|
+
return path4.join(possibleDirs[0], binaryName);
|
|
729
732
|
}
|
|
730
733
|
async executeBinary(args) {
|
|
731
|
-
const
|
|
732
|
-
const command = `"${binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
|
|
734
|
+
const command = `"${this.binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
|
|
733
735
|
try {
|
|
734
736
|
const { stdout, stderr } = await execAsync(command, {
|
|
735
737
|
maxBuffer: 10 * 1024 * 1024,
|