Skip to content
Permalink
Browse files

Add platform arg to scripts.

  • Loading branch information...
evcohen committed Mar 7, 2019
1 parent ecd8c38 commit 56ee682ee6fb14a87bfdd2172515412f6fcdcdac
Showing with 11 additions and 6 deletions.
  1. +7 −2 scripts/create-rule.js
  2. +4 −4 scripts/create-rule.md
@@ -12,9 +12,14 @@ const docBoilerplateGenerator = require('./boilerplate/doc');
const ruleName = argv._[0];
const author = argv.author || '$AUTHOR';
const description = argv.description || '$DESCRIPTION';
let platform = argv.platform || 'web';

const rulePath = path.resolve(`src/rules/${ruleName}.js`);
const testPath = path.resolve(`__tests__/src/rules/${ruleName}-test.js`);
if (platform !== 'native' || platform !== 'web') {
platform = 'web';
}

const rulePath = path.resolve(`src/rules/${platform}/${ruleName}.js`);
const testPath = path.resolve(`__tests__/src/rules/${platform}/${ruleName}-test.js`);
const docsPath = path.resolve(`docs/rules/${ruleName}.md`);

const jscodeshiftMain = jscodeshiftJSON.main;
@@ -1,14 +1,14 @@
# Rule Generator

```bash
$ node scripts/create-rule.js rule-name --author="Your name" --description="Description of the rule"
$ node scripts/create-rule.js rule-name --author="Your name" --description="Description of the rule" --platform=="native"
# OR with npm script alias
$ npm run create -- rule-name --author="Your name" --description="Description of rule"
$ npm run create -- rule-name --author="Your name" --description="Description of rule" --platform="web"
```

This script will generate three files with basic boilerplate for the given rule:
1. src/rules/${rule-name}.js
2. \__tests__/src/rules/${rule-name}-test.js
1. src/rules/${platform}/${rule-name}.js
2. \__tests__/src/rules/${platform}/${rule-name}-test.js
3. docs/rules/${rule-name}.md

If the rule already exists or is not specified in the correct format, an error will be thrown.

0 comments on commit 56ee682

Please sign in to comment.
You can’t perform that action at this time.