Skip to content

Commit ac37c65

Browse files
committed
Keep forgetting this is Git and not Mercurial.
1 parent ffb7f9e commit ac37c65

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/create-rule.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ const rulePath = path.resolve(`src/rules/${ruleName}.js`);
1414
const testPath = path.resolve(`__tests__/src/rules/${ruleName}-test.js`);
1515
const docsPath = path.resolve(`docs/rules/${ruleName}.md`);
1616

17+
const jscodeshiftJSON = require('jscodeshift/package.json');
18+
const jscodeshiftMain = jscodeshiftJSON.main;
19+
const jscodeshiftPath = require.resolve('jscodeshift');
20+
const jscodeshiftRoot = jscodeshiftPath.slice(
21+
0,
22+
jscodeshiftPath.indexOf(jscodeshiftMain)
23+
);
24+
1725
// Validate
1826
if (!ruleName) {
1927
throw new Error('Rule name is required');
@@ -34,8 +42,8 @@ fs.writeFileSync(docsPath, docBoilerplate);
3442
// Add the rule to the index
3543
exec([
3644
path.join(
37-
require.resolve('jscodeshift'),
38-
require('jscodeshift/package.json').bin.jscodeshift
45+
jscodeshiftRoot,
46+
jscodeshiftJSON.bin.jscodeshift
3947
),
4048
'./src/index.js',
4149
'-t ./scripts/addRuleToIndex.js',

0 commit comments

Comments
 (0)