Skip to content
Permalink
Browse files
fix(index): do not assume win32 usage for binaries
  • Loading branch information
Fdawgs committed Nov 30, 2021
1 parent fc420c9 commit bbd50d838b6dbc487233ac5cdaee0db657d64f93
Showing with 7 additions and 6 deletions.
  1. +5 −2 src/index.js
  2. +2 −4 src/index.test.js
@@ -75,15 +75,18 @@ class UnRTF {
constructor(binPath) {
if (binPath) {
this.unrtfPath = path.normalizeTrim(binPath);
} else {
// If not set, expect user to be using Win32
} else if (process.platform === "win32") {
this.unrtfPath = path.joinSafe(
__dirname,
"lib",
"win32",
"unrtf-0.19.3",
"bin"
);
} else {
throw new Error(
`${process.platform} UnRTF binaries are not provided, please pass the installation directory as a parameter to the UnRTF instance.`
);
}
}

@@ -2,7 +2,6 @@
/* eslint-disable security/detect-child-process */
/* eslint-disable security/detect-non-literal-fs-filename */
const isHtml = require("is-html");
const os = require("os");
const path = require("upath");
const semver = require("semver");
const { execFile } = require("child_process");
@@ -15,8 +14,7 @@ const testDirectory = `${__dirname}/../test_files/`;
const file = `${testDirectory}test-rtf-complex.rtf`;

let testBinaryPath;
const platform = os.platform();
switch (platform) {
switch (process.platform) {
// macOS
case "darwin":
testBinaryPath = "/usr/local/bin";
@@ -39,7 +37,7 @@ switch (platform) {
break;
}

if (platform === "win32") {
if (process.platform === "win32") {
describe("Constructor", () => {
test("Should convert RTF file to HTML without binary set, and use included Windows binary", async () => {
const unRtf = new UnRTF();

0 comments on commit bbd50d8

Please sign in to comment.