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

Consider when the file is used with pnpm isolated mode. #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Prettier-ing the file.
-> double quote, semicolon.
  • Loading branch information
sharky98 committed Sep 30, 2022
commit fea239a66b7494f035741de3bf73c61596498bd3
40 changes: 20 additions & 20 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");

/**
* Retrieve the absolute path to the `@mdi/svg` package.
*
*
* If using from the root of a project, it will return the `node_modules/@mdi/svg` path.
* Otherwise, it will fallback to 0.3.2 behavior (without validating that it exists).
*
*
* This help for pnpm in isolated mode where the 0.3.2 behavior try to find the `@mdi/svg` package
* somewhere in the `.pnpm` store.
*
* @param {string} overridePackageName
*
* @param {string} overridePackageName
* @returns the absolute path to the `@mdi/svg` package.
*/
const getSVGPackagePath = (overridePackageName = undefined) => {
const getSVGPackagePath = (overridePackageName = undefined) => {
const pkgName = overridePackageName || "svg";
const mdi_svg_path = path.resolve(
process.cwd(),
Expand All @@ -33,9 +33,9 @@ const path = require('path');

/**
* Read a file and return its content.
*
* @param {string} filename
* @param {string} overridePackageName
*
* @param {string} filename
* @param {string} overridePackageName
* @returns content of the file
*/
const readFile = (filename, overridePackageName = undefined) => {
Expand All @@ -46,13 +46,13 @@ const readFile = (filename, overridePackageName = undefined) => {
}

return fs.readFileSync(filepath, { encoding: "utf8" });
}
};

/**
* Read a JSON and return an object of the parsed JSON.
*
* @param {string} filename
* @param {string} overridePackageName
*
* @param {string} filename
* @param {string} overridePackageName
* @returns object of the parsed json
*/
const readJSONtoObject = (filename, overridePackageName = undefined) => {
Expand Down Expand Up @@ -82,27 +82,27 @@ const getMeta = (withPaths, overridePackageName = undefined) => {
};

exports.getVersionLight = () => {
return getVersion('light-svg');
}
return getVersion("light-svg");
};

exports.getMetaLight = (withPaths) => {
return getMeta(withPaths, 'light-svg');
}
return getMeta(withPaths, "light-svg");
};

exports.getVersion = getVersion;

exports.getMeta = getMeta;

exports.closePath = (path) => {
return path.replace(/(\d)M/g, '$1ZM');
return path.replace(/(\d)M/g, "$1ZM");
};

exports.write = (file, data) => {
fs.writeFileSync(file, data);
};

exports.read = (file) => {
return fs.readFileSync(file, 'utf8');
return fs.readFileSync(file, "utf8");
};

exports.exists = (file) => {
Expand Down