Skip to content

Commit

Permalink
convert source to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz committed Feb 8, 2023
1 parent 501ba72 commit 6e8b7f4
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/decrypt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fileExists } from "./utils";
import execute from "./spawn";
import { fileExists } from "./utils.js";
import execute from "./spawn.js";

export interface DecryptSettings {
/** The path for the encrypted pdf */
Expand Down
4 changes: 2 additions & 2 deletions src/encrypt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import execute from "./spawn";
import { fileExists, hyphenate } from "./utils";
import execute from "./spawn.js";
import { fileExists, hyphenate } from "./utils.js";

const EncryptDefaults = {
keyLength: 256,
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { DecryptSettings } from "./decrypt";
export { decrypt } from "./decrypt";
export type { EncryptOptions } from "./encrypt";
export { encrypt } from "./encrypt";
export type { DecryptSettings } from "./decrypt.js";
export { decrypt } from "./decrypt.js";
export type { EncryptOptions } from "./encrypt.js";
export { encrypt } from "./encrypt.js";
6 changes: 3 additions & 3 deletions src/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export default (callArguments: string[]): Promise<Buffer> => {
reject(error);
});
process.on("close", (code) => {
if (code !== 0) {
if (code === 0) {
resolve(Buffer.from(stdout.join("")));
} else {
// There is a problem from qpdf
reject(Buffer.from(stderr.join("")).toLocaleString());
} else {
resolve(Buffer.from(stdout.join("")));
}
});
});
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export const hyphenate = (variable: string): string =>
* @param file the path of the file to be tested.
*/
export const fileExists = (file: string): boolean => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
return !!existsSync(file);
};
2 changes: 1 addition & 1 deletion test/decrypt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import { decrypt } from "../src/decrypt";
import { decrypt } from "../src/decrypt.js";

test("Should not work if no input file is specified", async (t) => {
// @ts-expect-error This is what I'm testing
Expand Down
2 changes: 1 addition & 1 deletion test/encrypt-and-decrypt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import { encrypt, decrypt } from "../src";
import { encrypt, decrypt } from "../src/index.js";

const input = "test/example.pdf";

Expand Down
2 changes: 1 addition & 1 deletion test/encrypt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import { copyFile } from "node:fs/promises";
import { encrypt } from "../src/encrypt";
import { encrypt } from "../src/encrypt.js";

const input = "test/example.pdf";
const password = "1234";
Expand Down

0 comments on commit 6e8b7f4

Please sign in to comment.