You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-4Lines changed: 51 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ Usage:
50
50
$ css-codemod [files]
51
51
52
52
Commands:
53
-
[files] File path to transform. Glob patterns are supported.
53
+
[files] File path to transform. Note glob patterns are supported but must be wrapped in quotes.
54
54
55
55
For more info, run any command with the `--help` flag:
56
56
$ css-codemod --help
@@ -63,13 +63,60 @@ Options:
63
63
Examples:
64
64
css-codemod ./a.css
65
65
css-codemod ./src/a.css
66
-
css-codemod ./src/**/*.css
67
-
css-codemod ./**/*.css
66
+
css-codemod "./src/**/*.css"
67
+
css-codemod "./**/*.css"
68
68
```
69
69
70
70
## API
71
71
72
-
TODO(Document transform function API)
72
+
### `Transform`
73
+
74
+
Define a transform function. This type is provided to explicitly type the exported `transform` function. In general, this should be the only type that needs to be imported. The expected return value is either a CSS string or `null`. When returned a CSS string that will be written back to the original file. When returned `null`, nothing happens and the original file is skipped.
75
+
76
+
### `TransformFileInfo`
77
+
78
+
The first argument passed to the `transform` function. It's an object with metadata about the current file being processed by the transform.
79
+
80
+
-`path`: the resolved path of the file being transformed.
81
+
-`source`: the file contents source of the file being transformed.
82
+
83
+
### `TransformAPI`
84
+
85
+
The second argument passed to the `transform` function. It's an object with helpers provided by `css-codemod` to perform transformations.
86
+
87
+
-`parse`: parse a raw CSS string into an AST. This returns the root node of the underlying abstract syntax tree to perform mutations. This is performed with [PostCSS](https://postcss.org/) so the returned node is a PostCSS [Root](https://postcss.org/api/#root) node. Refer to the [PostCSS API documentation](https://postcss.org/api/) for documentation and various helpers.
0 commit comments