Skip to content

Commit 68eb065

Browse files
authored
👌 IMPROVE: Make compatabile with end-of-file-fixer hook (#4)
1 parent 4539b36 commit 68eb065

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# web-compile
22

3-
A CLI for compiling SCSS files to CSS, and associated pre-commit hook.
3+
[![PyPI][pypi-badge]][pypi-link]
4+
5+
A CLI to compile/minify SCSS & JS, and associated pre-commit hook.
46

57
This CLI is a small wrapper around [libsass-python](https://github.com/sass/libsass-python),
68
[rJSmin](http://opensource.perlig.de/rjsmin/) and [jinja2](https://jinja.palletsprojects.com),
@@ -11,6 +13,9 @@ and provide a pre-commit hook.
1113
and will be trialled in [sphinx-panels](https://github.com/executablebooks/sphinx-panels),
1214
and then [sphinx-book-theme](https://github.com/executablebooks/sphinx-book-theme).
1315

16+
[pypi-badge]: https://img.shields.io/pypi/v/web-compile.svg
17+
[pypi-link]: https://pypi.org/project/web-compile
18+
1419
## Installation
1520

1621
To use directly as a CLI:

tests/test_run_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_js_hash(src_folder: Path):
108108
assert result.exit_code == 3, result.output
109109

110110
assert (
111-
src_folder / "dist" / "example1.36fb66cd32ac08ace70a7132f8173a9b.js"
111+
src_folder / "dist" / "example1.4725d39478f0b1676dc24f7b1bbee0ae.js"
112112
).exists(), result.output
113113

114114

@@ -167,7 +167,7 @@ def test_full(src_folder: Path):
167167
text = (src_folder / "dist" / "example2.txt").read_text("utf8")
168168
# print(text)
169169
assert "example1.120bc14042c23711b51a07133e9dcabd.css" in text, text
170-
assert "example1.36fb66cd32ac08ace70a7132f8173a9b.js" in text, text
170+
assert "example1.4725d39478f0b1676dc24f7b1bbee0ae.js" in text, text
171171
assert len(list((src_folder / "dist").glob("*"))) == 7
172172

173173
# re-run

web_compile/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ def minify_js(
356356
)
357357
try:
358358
js_str = rjsmin.jsmin(input_path.read_text(), js_comments)
359+
# ensure compatibility with end-of-file-fixer
360+
js_str = js_str.rstrip() + os.linesep
359361
except Exception as err:
360362
compilation_errors[str(input_path)] = str(err)
361363
if continue_on_error:
@@ -438,6 +440,8 @@ def _get_compiled_name(path):
438440
jinja_str = jinja_env.from_string(
439441
input_path.read_text(jinja_encoding)
440442
).render()
443+
# ensure compatibility with end-of-file-fixer
444+
jinja_str = jinja_str.rstrip() + os.linesep
441445
except Exception as err:
442446
compilation_errors[str(input_path)] = str(err)
443447
if continue_on_error:

0 commit comments

Comments
 (0)