Created
March 23, 2023 00:06
-
-
Save derigible/3000033fed8fb306965e66b3cae00377 to your computer and use it in GitHub Desktop.
Update files that don't have the frozen_string_literal comment
This file contains 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 characters
#! /bin/zsh | |
set -e | |
rubocop | grep FrozenStringLiteralComment | awk '{ print $1 }' | awk -F ':' '{ print $1 }' | awk '{$1=$1};1' | xargs sed -i "" '1s/^/# frozen_string_literal: true\n\n/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This also works (and is probably the better way to do it):
Note that this will only work on projects that use git. The benefit of this approach though is it narrows the scope of changes to only those files that have been updated during a commit.