Last active
November 10, 2019 21:37
-
-
Save maxlath/c7c3a3809a0ac22c3ca315887570e20f to your computer and use it in GitHub Desktop.
Revisions
-
maxlath revised this gist
Nov 10, 2019 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,13 @@ #!/usr/bin/env node // To be run after bulk-decaffeinate is done // bulk-decaffeinate convert --num-workers 8 --config ~/bulk-decaffeinate.config.js // cleanup(){ // decaffeinate_cleanup.js "$@" && npm run lint-fix "$@" // } // // cleanup **/*.js const path = require('path') const fs = require('fs') -
maxlath created this gist
Nov 10, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env node const path = require('path') const fs = require('fs') const cleanupLine = line => { return line .replace(/^(\s+(?!(if|for))\w+) (\(.*\)) \{/g, '$1: $3 => {') .replace(/= function (\(.*\)) {/g, '= $1 => {') .replace(/=> function (\(.*\)) {/g, '=> $1 => {') .replace(/(^\s+if) (\(.*\)) { return\s?(.*) }/g, '$1 $2 return $3') .replace(/(^\s+if) (\(.*\)) { throw\s?(.*) }/g, '$1 $2 throw $3') .replace(/(^\s+else) { return\s?(.*) }/g, '$1 return $2') .replace(/(^\s+else) { throw\s?(.*) }/g, '$1 throw $2') .replace(/return done\(\)/, 'done()') .replace(/return it\(/, 'it(') } const update = file => { const current = fs.readFileSync(file).toString() const updated = current .split('\n') .map(cleanupLine) .join('\n') if (current !== updated) fs.writeFileSync(file, updated) } process.argv.slice(2) .map(file => path.resolve(file)) .forEach(update)