Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid relying on __dirname global constant #1237

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/plugin-print/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Path from "path";
import Url from 'url';
import bMFont from "load-bmfont";
import { isNodePattern, throwError } from "@jimp/utils";
import { measureText, measureTextHeight, splitLines } from "./measure-text";

const __filename = url.fileURLToPath(import.meta.url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does all compiled output have the correct code here?

ex:

  • cjs
  • esm
  • browser

Once verified will merge

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me check.
I can say for sure that esm is working.
the other two I have to check. any direction on how to do it correctly would be appreciated
Thanks!

const __dirname = Path.dirname(__filename);

function xOffsetBasedOnAlignment(constants, font, line, maxWidth, alignment) {
if (alignment === constants.HORIZONTAL_ALIGN_LEFT) {
return 0;
Expand Down