@@ -158,6 +158,27 @@ QUnit.module('codemod-cli', function (hooks) {
158158 ] ) ;
159159 } ) ;
160160
161+ QUnit . test ( 'should generate a codemod in a custom directory' , async function ( assert ) {
162+ let result = await execa ( EXECUTABLE_PATH , [
163+ 'generate' ,
164+ 'codemod' ,
165+ 'main' ,
166+ '--codemod-dir' ,
167+ 'other-dir' ,
168+ ] ) ;
169+
170+ assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
171+ assert . deepEqual ( walkSync ( codemodProject . path ( 'other-dir' ) ) , [
172+ 'main/' ,
173+ 'main/README.md' ,
174+ 'main/__testfixtures__/' ,
175+ 'main/__testfixtures__/basic.input.js' ,
176+ 'main/__testfixtures__/basic.output.js' ,
177+ 'main/index.js' ,
178+ 'main/test.js' ,
179+ ] ) ;
180+ } ) ;
181+
161182 QUnit . test ( 'should generate a hbs codemod' , async function ( assert ) {
162183 let result = await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' , '--type' , 'hbs' ] ) ;
163184
@@ -237,6 +258,27 @@ QUnit.module('codemod-cli', function (hooks) {
237258 assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
238259 } ) ;
239260
261+ QUnit . test ( 'should pass for an empty codemod in a custom directory' , async function ( assert ) {
262+ await execa ( EXECUTABLE_PATH , [
263+ 'generate' ,
264+ 'codemod' ,
265+ 'main' ,
266+ '--codemod-dir' ,
267+ 'other-transform-path' ,
268+ ] ) ;
269+ await execa ( EXECUTABLE_PATH , [
270+ 'generate' ,
271+ 'fixture' ,
272+ 'main' ,
273+ 'this-dot-owner' ,
274+ '--codemod-dir' ,
275+ 'other-transform-path' ,
276+ ] ) ;
277+
278+ let result = await execa ( EXECUTABLE_PATH , [ 'test' ] ) ;
279+ assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
280+ } ) ;
281+
240282 QUnit . test ( 'should fail when input and output do not match' , async function ( assert ) {
241283 await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' ] ) ;
242284 await execa ( EXECUTABLE_PATH , [ 'generate' , 'fixture' , 'main' , 'this-dot-owner' ] ) ;
@@ -415,6 +457,32 @@ QUnit.module('codemod-cli', function (hooks) {
415457 } ,
416458 } ) ;
417459 } ) ;
460+
461+ QUnit . test ( 'works with custom codemod directory' , async function ( assert ) {
462+ userProject . write ( {
463+ foo : { 'something.js' : 'let blah = bar' , 'other.js' : 'let blah = bar' } ,
464+ } ) ;
465+
466+ await execa (
467+ EXECUTABLE_PATH ,
468+ [ 'generate' , 'codemod' , 'secondary' , '--codemod-dir' , 'other-dir' ] ,
469+ {
470+ cwd : codemodProject . path ( ) ,
471+ }
472+ ) ;
473+
474+ await execa ( codemodProject . path ( 'bin/cli.js' ) , [
475+ codemodProject . path ( './other-dir/secondary/index.js' ) ,
476+ 'foo/*thing.js' ,
477+ ] ) ;
478+
479+ assert . deepEqual ( userProject . read ( ) , {
480+ foo : {
481+ 'something.js' : 'let halb = rab' ,
482+ 'other.js' : 'let blah = bar' ,
483+ } ,
484+ } ) ;
485+ } ) ;
418486 } ) ;
419487
420488 QUnit . module ( 'programmatic API' , function ( hooks ) {
0 commit comments