File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ const rulePath = path.resolve(`src/rules/${ruleName}.js`);
14
14
const testPath = path . resolve ( `__tests__/src/rules/${ ruleName } -test.js` ) ;
15
15
const docsPath = path . resolve ( `docs/rules/${ ruleName } .md` ) ;
16
16
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
+
17
25
// Validate
18
26
if ( ! ruleName ) {
19
27
throw new Error ( 'Rule name is required' ) ;
@@ -34,8 +42,8 @@ fs.writeFileSync(docsPath, docBoilerplate);
34
42
// Add the rule to the index
35
43
exec ( [
36
44
path . join (
37
- require . resolve ( 'jscodeshift' ) ,
38
- require ( 'jscodeshift/package.json' ) . bin . jscodeshift
45
+ jscodeshiftRoot ,
46
+ jscodeshiftJSON . bin . jscodeshift
39
47
) ,
40
48
'./src/index.js' ,
41
49
'-t ./scripts/addRuleToIndex.js' ,
You can’t perform that action at this time.
0 commit comments