Skip to content

Commit 8ab5311

Browse files
Merge pull request #80 from CodeshiftCommunity/feat/allow-specifying-multiple-transforms
Feat/allow specifying multiple transforms
2 parents 26e4a04 + 2f5f72f commit 8ab5311

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.changeset/rotten-pears-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeshift/cli': minor
3+
---
4+
5+
Adds the ability to specify a comma seperated list of transforms via the -t flag

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ program
1616
.usage('[global options] <file-paths>...')
1717
.option(
1818
'-t, --transform <value>',
19-
'The transform to run, will prompt for a transform if not provided and no module is passed',
19+
'The transform(s) to run, will prompt for a transform if not provided and no module is passed\nTo provide multiple transforms, separate them with commas (e.g. "-t t1,t2,t3")',
2020
)
2121
.option(
2222
'--packages <value>',

packages/cli/src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ export default async function main(paths: string[], flags: Flags) {
9494
}
9595

9696
if (flags.transform) {
97-
transforms.push(flags.transform);
97+
if (flags.transform.includes(',')) {
98+
flags.transform.split(',').forEach(t => transforms.push(t.trim()));
99+
} else {
100+
transforms.push(flags.transform);
101+
}
98102
}
99103

100104
if (flags.packages) {

website/docs/api/codeshift-cli.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ and run with:
3939

4040
### --transform, -t
4141

42-
The transform to run, transforms can be either a single file or directory with an index.
42+
Allows you to execute local transform file(s).
43+
44+
- Can be provided with a comma-separated list (see example below).
45+
- Transforms can be either a single file or directory containing an "index" file.
4346

4447
**example:**
4548

4649
- `$ codeshift-cli --transform codemods/my-special-mod /project/src/file.js`
4750
- `$ codeshift-cli --transform codemods/my-special-mod/index.ts /project/src/file.js`
51+
- `$ codeshift-cli --transform path/to/transform1.ts, path/to/transform2.ts, path/to/transform3.ts /project/src/file.js`
4852

4953
### --packages
5054

0 commit comments

Comments
 (0)