@yahoo/uds-mobile 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
 
@@ -53,27 +53,16 @@ function logError(message) {
53
53
  /**
54
54
  * Formats code using Prettier if available.
55
55
  */
56
- async function formatWithPrettier(content, prettierConfigPath) {
56
+ async function formatWithPrettier(content, filePath, prettierConfigPath) {
57
57
  try {
58
58
  const prettier = await import("prettier");
59
- let prettierConfig = {};
60
- if (prettierConfigPath) {
61
- const configPath = resolve(process.cwd(), prettierConfigPath);
62
- if (existsSync(configPath)) {
63
- const configContent = readFileSync(configPath, "utf-8");
64
- prettierConfig = JSON.parse(configContent);
65
- logStep("Using", `Prettier config: ${prettierConfigPath}`);
66
- } else logWarning(`Prettier config not found: ${prettierConfigPath}`);
67
- } else {
68
- const resolvedConfig = await prettier.resolveConfig(process.cwd());
69
- if (resolvedConfig) {
70
- prettierConfig = resolvedConfig;
71
- logStep("Found", "Prettier config in project");
72
- }
73
- }
59
+ const configPath = prettierConfigPath ? resolve(process.cwd(), prettierConfigPath) : void 0;
60
+ if (configPath && !existsSync(configPath)) logWarning(`Prettier config not found: ${prettierConfigPath}`);
61
+ const resolvedConfig = await prettier.resolveConfig(filePath, { ...configPath && { config: configPath } });
62
+ if (resolvedConfig) logStep("Found", "Prettier config in project");
74
63
  return await prettier.format(content, {
75
64
  parser: "typescript",
76
- ...prettierConfig
65
+ ...resolvedConfig
77
66
  });
78
67
  } catch {
79
68
  return content;
@@ -169,7 +158,7 @@ export const themes = {
169
158
 
170
159
  export const breakpoints = ${JSON.stringify(breakpoints, null, 2)};
171
160
  `;
172
- themeContent = await formatWithPrettier(themeContent, opts.prettierConfigPath);
161
+ themeContent = await formatWithPrettier(themeContent, outputFile, opts.prettierConfigPath);
173
162
  writeFileSync(outputFile, themeContent);
174
163
  const relativePath = outputFile.replace(cwd + "/", "");
175
164
  if (!opts.silent) logStep("Generated", relativePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-mobile",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "uds-mobile": "./cli/uds-mobile.js"