Skip to content

Commit

Permalink
Framework - Support named export codemod (#11688)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnmoon committed Apr 5, 2017
1 parent 1191992 commit 4f6fb14
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions bin/codemods/generate-named-exports-from-default
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

/*
This codemod generates named exports given a `default export { ... }`.
How to use:
./bin/codemods/commonjs-exports-named path-to-transform/
*/

const path = require( 'path' );
const child_process = require( 'child_process' );

const args = process.argv.slice( 2 );
if ( args.length === 0 ) {
process.stdout.write( 'No files to transform\n' );
process.exit( 0 );
}

const binArgs = [
'-t',
'node_modules/5to6-codemod/transforms/named-export-generation.js',
'--extensions=js,jsx',
args[0],
];
const binPath = path.join( '.', 'node_modules', '.bin', 'jscodeshift' )
const jscodeshift = child_process.spawn( binPath, binArgs );

jscodeshift.stdout.on( 'data', ( data ) => {
process.stdout.write( data );
});

jscodeshift.stderr.on( 'data', ( data ) => {
process.stderr.write( data );
});

0 comments on commit 4f6fb14

Please sign in to comment.