Skip to content

Commit 4d16322

Browse files
committed
Ignore underscored files when compiling a directory.
1 parent 0ff0e0e commit 4d16322

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

sass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def compile_dirname(
149149
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
150150
for dirpath, _, filenames in os.walk(search_path):
151151
filenames = [
152-
filename for filename in filenames if filename.endswith('.scss')
152+
filename for filename in filenames
153+
if filename.endswith('.scss') and not filename.startswith('_')
153154
]
154155
for filename in filenames:
155156
input_filename = os.path.join(dirpath, filename)

sasstests.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ def test_successful(self):
698698
# Make sure we don't compile non-scss files
699699
write_file(os.path.join(input_dir, 'baz.txt'), 'Hello der')
700700

701-
# the api for this is weird, why does it need source?
702701
sass.compile(dirname=(input_dir, output_dir))
703702
assert os.path.exists(output_dir)
704703
assert os.path.exists(os.path.join(output_dir, 'foo'))
@@ -711,6 +710,17 @@ def test_successful(self):
711710
self.assertEqual(contentsf1, 'a b {\n width: 100%; }\n')
712711
self.assertEqual(contentsf2, 'foo {\n width: 100%; }\n')
713712

713+
def test_ignores_underscored_files(self):
714+
with tempdir() as tmpdir:
715+
input_dir = os.path.join(tmpdir, 'input')
716+
output_dir = os.path.join(tmpdir, 'output')
717+
os.mkdir(input_dir)
718+
write_file(os.path.join(input_dir, 'f1.scss'), '@import "f2";')
719+
write_file(os.path.join(input_dir, '_f2.scss'), 'a{color:red}')
720+
721+
sass.compile(dirname=(input_dir, output_dir))
722+
assert not os.path.exists(os.path.join(output_dir, '_f2.css'))
723+
714724
def test_error(self):
715725
with tempdir() as tmpdir:
716726
input_dir = os.path.join(tmpdir, 'input')

0 commit comments

Comments
 (0)