Skip to content

Commit 6347f4e

Browse files
Robert Jacksonrondale-sc
andcommitted
Update README's with update-docs command info.
Co-authored-by: Jonathan Jackson <[email protected]>
1 parent 2bf9a23 commit 6347f4e

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ codemod-cli generate fixture <name of codemod> <name of fixture>
5050
This sets up two new files in `transforms/<name of codemod>/__testfixtures__/` using the fixture name
5151
you provided. These fixtures are used by the testing harness to verify that your codemod is working properly.
5252

53+
Once you have things just how you like them with your new codemod (and your tests are passing :wink:) you
54+
can update your project's README and your transforms README via:
55+
56+
```
57+
codemod-cli update-docs
58+
```
5359

5460
Contributing
5561
------------------------------------------------------------------------------

commands/global/new.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ module.exports.handler = function handler(options) {
5252
### Running tests
5353
5454
* \`yarn test\`
55+
56+
### Update Documentation
57+
58+
* \`yarn update-docs\`
5559
`,
5660
'utf8'
5761
);
@@ -62,6 +66,7 @@ module.exports.handler = function handler(options) {
6266
version: '0.1.0',
6367
scripts: {
6468
test: 'codemod-cli test',
69+
'update-docs': 'codemod-cli update-docs',
6570
},
6671
bin: './bin/cli.js',
6772
keywords: ['codemod-cli'],

commands/local/update-docs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ function updateTransformREADME(transformName) {
3434

3535
let fixtureDir = `transforms/${transformName}/__testfixtures__`;
3636

37+
if (!fs.existsSync(fixtureDir)) {
38+
// project does not include fixtures (perhaps using different testing
39+
// setup)
40+
return;
41+
}
42+
3743
fs.readdirSync(fixtureDir)
3844
.filter(filename => /\.input$/.test(path.basename(filename, path.extname(filename))))
3945
.forEach(filename => {

0 commit comments

Comments
 (0)