Skip to content

Commit

Permalink
Remove mention of the deleted map files (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow authored Oct 19, 2022
1 parent ca19b68 commit 0fd04bf
Show file tree
Hide file tree
Showing 38 changed files with 28 additions and 49 deletions.
39 changes: 27 additions & 12 deletions dsfr/management/commands/trim_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,47 @@ class Command(BaseCommand):

def handle(self, *args, **options):
print("Delete CSS map files and non-minified CSS files")
count = 0
deleted_files = 0
all_css_map_files = self.get_files_by_ext("*.css.map")
for file in all_css_map_files:
os.remove(file)
count += 1
deleted_files += 1

all_full_css_files = self.get_non_minified_files_by_ext("*.css", ".min.css")
for file in all_full_css_files:
os.remove(file)
count += 1
deleted_files += 1

print(f"{count} files deleted.")
print(f"{deleted_files} files deleted.")

print("Delete JS map files and non-minified files")
count = 0
all_css_map_files = self.get_files_by_ext("*.js.map")
for file in all_css_map_files:
deleted_files = 0
all_js_map_files = self.get_files_by_ext("*.js.map")
for file in all_js_map_files:
os.remove(file)
count += 1
deleted_files += 1

all_full_css_files = self.get_non_minified_files_by_ext("*.js", ".min.js")
for file in all_full_css_files:
all_full_js_files = self.get_non_minified_files_by_ext("*.js", ".min.js")
for file in all_full_js_files:
os.remove(file)
count += 1
deleted_files += 1

print(f"{deleted_files} files deleted.")

print("Removing mentions of deleted files")
edited_files = 0
all_minified_js_files = self.get_files_by_ext("*.min.js")
for filename in all_minified_js_files:
with open(filename, "r+") as file:
original_content = file.readlines()
file.seek(0)
for line in original_content:
if "//# sourceMappingURL=" not in line:
file.write(line)
file.truncate()
edited_files += 1

print(f"{count} files deleted.")
print(f"{edited_files} files edited.")

def get_files_by_ext(self, extension) -> list:
return [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dsfr/static/dsfr/dist/component/component.module.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dsfr/static/dsfr/dist/component/component.nomodule.min.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0fd04bf

Please sign in to comment.