A collection of JSCodemods
Note: you will need to pass in the path to a config script for generating the import statements. See config.example.js
cd transformers
jscodeshift -t ./angular-injected-dep-to-es6-import.js /path/to/your-angular-file.js --config='/absolute/path/to/config.example.js'
Example:
- Input:
'use strict';
angular.module('angularApp')
.factory('helloWorld', helloWorld);
function helloWorld($http, $q, helloWorldConstant) {
}
- Output:
'use strict';
import { $http, $q } from '../../angularDeps';
import helloWorldConstant from '../../helloWorld.constant';
angular.module('angularApp')
.factory('helloWorld', helloWorld);
function helloWorld() {
}
cd /path/to/angular-project
jscodeshift -s -t /path/to/jscodemod-collection/transformers/angular-collect.js --ignore-config=.gitignore ./client
Will output
"helloWorldConstant": "path/to/helloWorld.constant.js",
"helloWorldService": "path/to/helloWorld.service.js",
You can then copy the output to a JSON file that can be used for later. See config.example.js
Node ^6
git clone [email protected]:baopham/jscodemod-collection.git
yarn install
yarn install jscodeshift -g
MIT
Bao Pham