noupload 1.0.2 → 1.0.3
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.js +21 -2
- package/package.json +1 -1
- package/src/utils/detect.ts +25 -1
- package/dist/index.cjs +0 -205
package/dist/index.js
CHANGED
|
@@ -1036,6 +1036,25 @@ __export(exports_detect, {
|
|
|
1036
1036
|
detectFFmpeg: () => detectFFmpeg,
|
|
1037
1037
|
checkTool: () => checkTool
|
|
1038
1038
|
});
|
|
1039
|
+
import { execSync } from "node:child_process";
|
|
1040
|
+
function which(name) {
|
|
1041
|
+
try {
|
|
1042
|
+
if (typeof Bun !== "undefined" && Bun.which) {
|
|
1043
|
+
const path = Bun.which(name);
|
|
1044
|
+
if (path)
|
|
1045
|
+
return path;
|
|
1046
|
+
}
|
|
1047
|
+
} catch {}
|
|
1048
|
+
try {
|
|
1049
|
+
const cmd = process.platform === "win32" ? `where ${name}` : `which ${name}`;
|
|
1050
|
+
const result = execSync(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] });
|
|
1051
|
+
const path = result.trim().split(`
|
|
1052
|
+
`)[0];
|
|
1053
|
+
return path || null;
|
|
1054
|
+
} catch {
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1039
1058
|
async function detectTool(name) {
|
|
1040
1059
|
if (toolCache.has(name)) {
|
|
1041
1060
|
const cached = toolCache.get(name);
|
|
@@ -1043,7 +1062,7 @@ async function detectTool(name) {
|
|
|
1043
1062
|
return cached;
|
|
1044
1063
|
}
|
|
1045
1064
|
try {
|
|
1046
|
-
const path =
|
|
1065
|
+
const path = which(name);
|
|
1047
1066
|
if (path) {
|
|
1048
1067
|
const info2 = { available: true, path };
|
|
1049
1068
|
toolCache.set(name, info2);
|
|
@@ -41014,7 +41033,7 @@ var require_defaultOptions = __commonJS((exports, module) => {
|
|
|
41014
41033
|
|
|
41015
41034
|
// node_modules/tesseract.js/src/worker/node/defaultOptions.js
|
|
41016
41035
|
var require_defaultOptions2 = __commonJS((exports, module) => {
|
|
41017
|
-
var __dirname = "/
|
|
41036
|
+
var __dirname = "/home/runner/work/nouploadcli/nouploadcli/node_modules/tesseract.js/src/worker/node";
|
|
41018
41037
|
var path = __require("path");
|
|
41019
41038
|
var defaultOptions = require_defaultOptions();
|
|
41020
41039
|
module.exports = {
|
package/package.json
CHANGED
package/src/utils/detect.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
1
2
|
import { toolFound, toolNotFound } from './logger';
|
|
2
3
|
|
|
3
4
|
export interface ToolInfo {
|
|
@@ -9,6 +10,29 @@ export interface ToolInfo {
|
|
|
9
10
|
// Cache for detected tools
|
|
10
11
|
const toolCache = new Map<string, ToolInfo>();
|
|
11
12
|
|
|
13
|
+
// Cross-platform which command
|
|
14
|
+
function which(name: string): string | null {
|
|
15
|
+
try {
|
|
16
|
+
// Try Bun.which first if available (faster)
|
|
17
|
+
if (typeof Bun !== 'undefined' && Bun.which) {
|
|
18
|
+
const path = Bun.which(name);
|
|
19
|
+
if (path) return path;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
// Bun.which not available, fall through
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Fallback to shell command
|
|
27
|
+
const cmd = process.platform === 'win32' ? `where ${name}` : `which ${name}`;
|
|
28
|
+
const result = execSync(cmd, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
29
|
+
const path = result.trim().split('\n')[0];
|
|
30
|
+
return path || null;
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
// Detect if a tool is available on the system
|
|
13
37
|
export async function detectTool(name: string): Promise<ToolInfo> {
|
|
14
38
|
// Check cache first
|
|
@@ -18,7 +42,7 @@ export async function detectTool(name: string): Promise<ToolInfo> {
|
|
|
18
42
|
}
|
|
19
43
|
|
|
20
44
|
try {
|
|
21
|
-
const path =
|
|
45
|
+
const path = which(name);
|
|
22
46
|
if (path) {
|
|
23
47
|
const info: ToolInfo = { available: true, path };
|
|
24
48
|
toolCache.set(name, info);
|