Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffy-g committed Jan 5, 2024
1 parent 9880037 commit d9d01c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions cjs/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports.localeGetters = exports.purgeExtraToken = exports.getEnvLocale = void 0;
const lcid = require("lcid");
const cp = require("child_process");
const { execFile, execFileSync } = cp;
const defaultLocale = "en_US";
/**
* @template R
* @typedef {{
Expand All @@ -28,7 +29,6 @@ const { execFile, execFileSync } = cp;
/**
* @typedef {ArrayLike<[() => Promise<string>, () => string]>[0]} TAsyncSyncPair
*/
const defaultLocale = "en_US";
/**
* @typedef {cp.ExecFileException} ExecFileException
* @typedef {"defaults" | "locale" | "wmic"} TLocalCmdToken
Expand Down Expand Up @@ -78,9 +78,8 @@ function validate(result, processor) {
if (typeof result === "string" && result.length) {
return processor ? processor(result) : result.trim();
}
/* istanbul ignore next */
if (result instanceof Error) {
console.error(result);
else {
console.info(result.message);
}
return defaultLocale;
}
Expand Down
7 changes: 3 additions & 4 deletions esm/lib.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import * as lcid from "lcid";
import * as cp from "child_process";
const { execFile, execFileSync } = cp;
const defaultLocale = "en_US";
/**
* @template R
* @typedef {{
Expand All @@ -25,7 +26,6 @@ const { execFile, execFileSync } = cp;
/**
* @typedef {ArrayLike<[() => Promise<string>, () => string]>[0]} TAsyncSyncPair
*/
const defaultLocale = "en_US";
/**
* @typedef {cp.ExecFileException} ExecFileException
* @typedef {"defaults" | "locale" | "wmic"} TLocalCmdToken
Expand Down Expand Up @@ -75,9 +75,8 @@ function validate(result, processor) {
if (typeof result === "string" && result.length) {
return processor ? processor(result) : result.trim();
}
/* istanbul ignore next */
if (result instanceof Error) {
console.error(result);
else {
console.info(result.message);
}
return defaultLocale;
}
Expand Down

0 comments on commit d9d01c9

Please sign in to comment.