Skip to content

Commit

Permalink
fixed handling of file path for CLI executions
Browse files Browse the repository at this point in the history
following scenarios did not work:
- absolute file path to PDF file
- Windows file path to PDF file (because it contains backslashes instead of slashes)
  • Loading branch information
FibreFoX committed Sep 16, 2024
1 parent 8604cc9 commit 4eb681d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @ts-check
import { promises as fs } from "node:fs";
import { parseArgs } from "node:util";
import { join } from "node:path";
import { join, basename, resolve } from "node:path";
import { pdf } from "../dist/index.js";

const { values, positionals } = parseArgs({
Expand All @@ -25,10 +25,10 @@ if (!inputFile) {

/** the name of the file, without the file extension */
const inputFileBaseName = /** @type {string} */ (
inputFile.split("/").at(-1)
basename(inputFile)
).replace(/\.pdf$/, "");

const fullInputFilePath = join(process.cwd(), inputFile);
const fullInputFilePath = resolve(process.cwd(), inputFile);
const outputFolder = join(process.cwd(), values.output || "");

async function main() {
Expand Down

0 comments on commit 4eb681d

Please sign in to comment.