Closure Libray codemod scripts
$ npm install -D jscodeshift @toshi-toma/closure-codemod
$ jscodeshift -t node_modules/@toshi-toma/closure-codemod/transforms/<codemod-script-name>.ts <file or directory>
You can use the -d
option for a dry-run and use -p
to print the output for comparison.
$ jscodeshift -t node_modules/@toshi-toma/closure-codemod/transforms/<codemod-script-name>.ts <file or directory> -d -p
$ jscodeshift -t node_modules/@toshi-toma/closure-codemod/transforms/goog-is-to-native-code.ts <file or directory>
Delete goog.is(Def|Null|DefAndNotNull|String|Boolean|Number) from base.js.
https://github.com/google/closure-library/releases/tag/v20200204
$ jscodeshift -t node_modules/@toshi-toma/closure-codemod/transforms/goog-object-to-native-code.ts <file or directory>
Deprecate goog.json.parse. Use JSON.parse. https://github.com/google/closure-library/commit/01e59bb44b306201078fd40eafcc8d36734cfee3
This script handle quotes
option.
single
- default. transform with single quote.double
- transform with double quote
$ jscodeshift -t node_modules/@toshi-toma/closure-codemod/transforms/goog-object-to-native-code.ts <file or directory> --quotes=single