Skip to content

Commit

Permalink
fix: fix parsing for non-english systems (#24)
Browse files Browse the repository at this point in the history
* Force english output

Force console output to english to make it work on non-english systems

* Fix PrinterData mapping for non-english systems
  • Loading branch information
ovi1337 authored Nov 7, 2023
1 parent aec5485 commit 4fe8bdf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/get-default-printer/get-default-printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getPrinterName(output: string): string {
}

async function getPrinterData(printer: string): Promise<Printer> {
const { stdout } = await execAsync(`lpstat -lp ${printer}`);
const { stdout } = await execAsync(`SOFTWARE= LANG=C lpstat -lp ${printer}`);
return {
printer,
status: stdout.split(/.*is\s(\w+)\..*/gm)[1],
Expand Down
2 changes: 1 addition & 1 deletion src/get-printers/get-printers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import parsePrinterAttribute from "../utils/parse-printer-attribute";

export default async function getPrinters(): Promise<Printer[]> {
try {
const { stdout } = await execAsync("lpstat -lp");
const { stdout } = await execAsync("SOFTWARE= LANG=C lpstat -lp");

const isThereAnyPrinter = stdout.match("printer");
if (!isThereAnyPrinter) return [];
Expand Down

0 comments on commit 4fe8bdf

Please sign in to comment.