summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2021-01-15 17:42:56 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2021-01-15 17:42:56 (GMT)
commit80526c0055ff0c685e5a4fb8fa876c27b6ac0c5b (patch)
tree6adcde7bc9929157139b5ffccad5369c3a62a190
parent793419c97ac3efeebeae86b1095176eac784fb8e (diff)
downloadmisc-fred-80526c0055ff0c685e5a4fb8fa876c27b6ac0c5b.zip
misc-fred-80526c0055ff0c685e5a4fb8fa876c27b6ac0c5b.tar.gz
misc-fred-80526c0055ff0c685e5a4fb8fa876c27b6ac0c5b.tar.bz2
sassw: add support for building multiple files
-rwxr-xr-xbin/sassw44
1 files changed, 25 insertions, 19 deletions
diff --git a/bin/sassw b/bin/sassw
index 1c2210a..0aa0b35 100755
--- a/bin/sassw
+++ b/bin/sassw
@@ -19,28 +19,32 @@ if os.path.isdir(filename):
scss_filenames = [x for x in os.listdir(filename) if not x.startswith('_') and x.endswith('.scss')]
if not scss_filenames:
print('Error: directory specified but no proper scss file within.', file=sys.stderr)
- filename = os.path.join(filename, scss_filenames[0])
+ filenames = [os.path.join(filename, x) for x in scss_filenames]
+else:
+ filenames = sys.argv[1:]
def build():
global sources, directories
- result = subprocess.run(
- ['sassc', '-mauto', filename, filename.replace('.scss', '.css')],
- capture_output=True,
- text=True)
- sys.stdout.write(result.stdout)
- sys.stderr.write(result.stderr)
- if result.returncode:
- # error
- with open(filename.replace('.scss', '.css'), 'w') as fd:
- print('''body::before {
- white-space: pre;
- font-family: monospace;
- content: "%s";
- }''' % result.stderr.replace('\n', '\\A').replace('"', '\\"'),
- file=fd)
- basepath = os.path.abspath(os.path.dirname(filename))
- sources = [os.path.abspath(os.path.join(basepath, x)) for x in json.load(open(filename.replace('.scss', '.css.map')))['sources']]
- directories = set([os.path.dirname(x) for x in sources])
+ directories = set()
+ for filename in filenames:
+ result = subprocess.run(
+ ['sassc', '-mauto', filename, filename.replace('.scss', '.css')],
+ capture_output=True,
+ text=True)
+ sys.stdout.write(result.stdout)
+ sys.stderr.write(result.stderr)
+ if result.returncode:
+ # error
+ with open(filename.replace('.scss', '.css'), 'w') as fd:
+ print('''body::before {
+ white-space: pre;
+ font-family: monospace;
+ content: "%s";
+ }''' % result.stderr.replace('\n', '\\A').replace('"', '\\"'),
+ file=fd)
+ basepath = os.path.abspath(os.path.dirname(filename))
+ sources = [os.path.abspath(os.path.join(basepath, x)) for x in json.load(open(filename.replace('.scss', '.css.map')))['sources']]
+ directories = directories.union(set([os.path.dirname(x) for x in sources]))
class EventManager(pyinotify.ProcessEvent):
def process_default(self, event):
@@ -51,6 +55,8 @@ class EventManager(pyinotify.ProcessEvent):
build()
print(f' ({time.time() - t0:.2f}s)')
+
+print('>>> Building %s' % ' '.join(filenames))
build()
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, default_proc_fun=EventManager())