@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.cjs
CHANGED
|
@@ -737,36 +737,38 @@ var fs3 = __toESM(require("fs"));
|
|
|
737
737
|
var import_util = require("util");
|
|
738
738
|
var execAsync = (0, import_util.promisify)(import_child_process2.exec);
|
|
739
739
|
var SqliteExecutor = class {
|
|
740
|
-
binaryPath
|
|
740
|
+
binaryPath;
|
|
741
741
|
dbPath;
|
|
742
742
|
constructor(dbPath) {
|
|
743
743
|
this.dbPath = dbPath;
|
|
744
|
+
this.binaryPath = this.getBinaryPath();
|
|
744
745
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
746
|
+
getBinaryPath() {
|
|
747
|
+
const possibleDirs = [
|
|
748
|
+
path4.resolve(process.cwd(), ".dbcube", "bin"),
|
|
749
|
+
path4.resolve(process.cwd(), "node_modules", ".dbcube", "bin"),
|
|
750
|
+
path4.resolve(__dirname, "..", "bin")
|
|
751
|
+
];
|
|
752
|
+
const platform2 = process.platform;
|
|
753
|
+
const extension = platform2 === "win32" ? ".exe" : "";
|
|
754
|
+
const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
|
|
755
|
+
for (const dir of possibleDirs) {
|
|
756
|
+
const fullPath = path4.join(dir, binaryName);
|
|
757
|
+
if (fs3.existsSync(fullPath)) {
|
|
758
|
+
return fullPath;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
const fallbackName = `sqlite-engine${extension}`;
|
|
762
|
+
for (const dir of possibleDirs) {
|
|
763
|
+
const fullPath = path4.join(dir, fallbackName);
|
|
764
|
+
if (fs3.existsSync(fullPath)) {
|
|
765
|
+
return fullPath;
|
|
759
766
|
}
|
|
760
|
-
const platform2 = process.platform;
|
|
761
|
-
const extension = platform2 === "win32" ? ".exe" : "";
|
|
762
|
-
const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
|
|
763
|
-
this.binaryPath = path4.join(binDir, binaryName);
|
|
764
767
|
}
|
|
765
|
-
return
|
|
768
|
+
return path4.join(possibleDirs[0], binaryName);
|
|
766
769
|
}
|
|
767
770
|
async executeBinary(args) {
|
|
768
|
-
const
|
|
769
|
-
const command = `"${binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
|
|
771
|
+
const command = `"${this.binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
|
|
770
772
|
try {
|
|
771
773
|
const { stdout, stderr } = await execAsync(command, {
|
|
772
774
|
maxBuffer: 10 * 1024 * 1024,
|