Skip to content

Commit ee6a925

Browse files
committedAug 26, 2024·
Try to fix some windows issues.
1 parent cc3501f commit ee6a925

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed
 

‎package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nosferatu500/textract-lite",
3-
"version": "7.0.9",
3+
"version": "7.0.11",
44
"type": "module",
55
"homepage": "https://github.com/nosferatu500/textract-lite",
66
"description": "Extracting text from files of various type including txt, doc, docx.",
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"engines": {
17-
"node": ">=20"
17+
"node": ">=20.9"
1818
},
1919
"repository": {
2020
"type": "git",

‎src/extract.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "fs";
22
import path from "path";
33

4-
import { fileURLToPath } from "node:url";
4+
import { fileURLToPath, pathToFileURL } from "node:url";
55

66
const __filename = fileURLToPath(import.meta.url);
77
const __dirname = path.dirname(__filename);
@@ -27,7 +27,7 @@ async function initializeExtractors() {
2727
hasInitialized = true;
2828

2929
// discover available extractors
30-
const extractors = await Promise.all(fs.readdirSync(extractorPath).map(async (item: any) => {
30+
const extractors = await Promise.all(fs.readdirSync(pathToFileURL(extractorPath)).map(async (item: any) => {
3131
const fullExtractorPath = path.join(extractorPath, item);
3232
// get the extractor
3333
const { default: extractor } = await import(fullExtractorPath);

‎src/extractors/text.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import path from "path";
33
import iconv from "iconv-lite";
44
import jschardet from "jschardet";
55
import { cleanseText } from "../utils.js";
6+
import { pathToFileURL } from "node:url";
67

78
function extractText(filePath: string, options: any): Promise<string | Error> {
89
return new Promise((resolve, reject) => {
9-
fs.readFile(filePath, function (error, data) {
10+
fs.readFile(pathToFileURL(filePath), function (error, data) {
1011
let encoding;
1112
let decoded;
1213
let detectedEncoding;

0 commit comments

Comments
 (0)
Please sign in to comment.