Skip to content

Commit

Permalink
refactor: deconstruct imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 2, 2023
1 parent 5c210f3 commit dbe1051
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions scripts/license-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"use strict";

const { promisify } = require("util");
const checker = require("license-checker");
const { init } = require("license-checker");
const copyLeftLicenses = require("spdx-copyleft");

const init = promisify(checker.init);
const check = promisify(init);
const path = require("upath");

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ async function checkLicenses() {
// Merge copyleft licenses with deprecated licenses list
copyLeftLicenses.push(...deprecatedLicenseList);

const licenses = await init({
const licenses = await check({
direct: true,
production: true,
start: path.joinSafe(__dirname, ".."),
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const { execFile, spawn } = require("child_process");
const { promisify } = require("util");
const fs = require("fs/promises");
const { readFile } = require("fs/promises");
const path = require("upath");
const semver = require("semver");
const { gt, lt } = require("semver");

const execFileAsync = promisify(execFile);

Expand Down Expand Up @@ -42,7 +42,7 @@ function parseOptions(acceptedOptions, options, version) {
if (
acceptedOptions[key].minVersion &&
version &&
semver.lt(version, acceptedOptions[key].minVersion)
lt(version, acceptedOptions[key].minVersion)
) {
invalidArgs.push(
`Invalid option provided for the current version of the binary used. '${key}' was introduced in v${acceptedOptions[key].minVersion}, but received v${version}`
Expand All @@ -53,7 +53,7 @@ function parseOptions(acceptedOptions, options, version) {
if (
acceptedOptions[key].maxVersion &&
version &&
semver.gt(version, acceptedOptions[key].maxVersion)
gt(version, acceptedOptions[key].maxVersion)
) {
invalidArgs.push(
`Invalid option provided for the current version of the binary used. '${key}' is only present up to v${acceptedOptions[key].maxVersion}, but received v${version}`
Expand Down Expand Up @@ -166,7 +166,7 @@ class UnRTF {
let buff;
try {
// eslint-disable-next-line security/detect-non-literal-fs-filename
buff = await fs.readFile(path.normalizeTrim(file));
buff = await readFile(path.normalizeTrim(file));
} catch {
throw new Error("File missing");
}
Expand Down
6 changes: 3 additions & 3 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { execFile } = require("child_process");
const { promisify } = require("util");
const isHtml = require("is-html");
const path = require("upath");
const semver = require("semver");
const { gt, lte } = require("semver");
const generateCombos = require("../test_resources/utils/genCombos");

const execFileAsync = promisify(execFile);
Expand Down Expand Up @@ -210,7 +210,7 @@ describe("Convert function", () => {
noPictures: true,
outputRtf: true,
};
if (semver.lte(version, "0.21.3")) {
if (lte(version, "0.21.3")) {
await expect(unRtf.convert(file, options)).rejects.toThrow(
`Invalid option provided for the current version of the binary used. 'outputRtf' was introduced in v0.21.3, but received v${version}`
);
Expand All @@ -223,7 +223,7 @@ describe("Convert function", () => {
noPictures: true,
outputPs: true,
};
if (semver.gt(version, "0.19.4")) {
if (gt(version, "0.19.4")) {
await expect(unRtf.convert(file, options)).rejects.toThrow(
`Invalid option provided for the current version of the binary used. 'outputPs' is only present up to v0.19.4, but received v${version}`
);
Expand Down

0 comments on commit dbe1051

Please sign in to comment.