@jsrepo/transform-prettier 0.0.1-beta.0 → 0.0.1-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -42
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,42 +1 @@
1
- import path from "node:path";
2
- import * as prettier from "prettier";
3
-
4
- //#region src/index.ts
5
- /**
6
- * A transform plugin for jsrepo to format code with prettier.
7
- * @example
8
- * ```ts
9
- * import { defineConfig } from "jsrepo";
10
- * import prettier from "@jsrepo/transform-prettier";
11
- *
12
- * export default defineConfig({
13
- * // ...
14
- * transforms: [prettier()],
15
- * });
16
- * ```
17
- *
18
- * @param options - The options for the transform plugin.
19
- */
20
- function src_default(options = {}) {
21
- const configPromise = prettier.resolveConfig(path.join(process.cwd(), options.configFile ?? ".prettierrc"));
22
- return { transform: async (code, opts) => {
23
- const config = await configPromise;
24
- return { code: await tryFormat(code, {
25
- fileName: opts.fileName,
26
- config
27
- }) };
28
- } };
29
- }
30
- function tryFormat(code, { fileName, config }) {
31
- try {
32
- return prettier.format(code, {
33
- ...config,
34
- filepath: fileName
35
- });
36
- } catch {
37
- return;
38
- }
39
- }
40
-
41
- //#endregion
42
- export { src_default as default };
1
+ import e from"node:path";import*as t from"prettier";function n(n={}){let i=t.resolveConfig(e.join(process.cwd(),n.configFile??`.prettierrc`));return{transform:async(e,t)=>{let n=await i;return{code:await r(e,{fileName:t.fileName,config:n})}}}}function r(e,{fileName:n,config:r}){try{return t.format(e,{...r,filepath:n})}catch{return}}export{n as default};
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@jsrepo/transform-prettier",
3
3
  "description": "A transform plugin for jsrepo to format code with prettier.",
4
- "version": "0.0.1-beta.0",
4
+ "version": "0.0.1-beta.1",
5
5
  "license": "MIT",
6
- "homepage": "https://jsrepo.dev",
6
+ "homepage": "https://v3.jsrepo.dev",
7
7
  "author": {
8
8
  "name": "Aidan Bleser",
9
9
  "url": "https://github.com/ieedan"
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "peerDependencies": {
36
36
  "prettier": "3.x",
37
- "jsrepo": "3.0.0-beta.0"
37
+ "jsrepo": "3.0.0-beta.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "tsdown": "^0.15.9",