summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-08-25 15:48:20 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-08-25 15:48:20 (GMT)
commitb351f2e8aa1021151bcd750674e72ed5d2d7e203 (patch)
tree81bb4383b0fc7248b21ad642a8ab441477dbe3f6
parentbad53ddec42b27952e51bfc50ef951eaa60500f3 (diff)
downloadmisc-fred-b351f2e8aa1021151bcd750674e72ed5d2d7e203.zip
misc-fred-b351f2e8aa1021151bcd750674e72ed5d2d7e203.tar.gz
misc-fred-b351f2e8aa1021151bcd750674e72ed5d2d7e203.tar.bz2
sassw: write errors to css file, like ruby-sass
-rwxr-xr-xbin/sassw15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/sassw b/bin/sassw
index f936346..ca35bff 100755
--- a/bin/sassw
+++ b/bin/sassw
@@ -23,7 +23,20 @@ if os.path.isdir(filename):
def build():
global sources, directories
- subprocess.call(['sassc', '-mauto', filename, filename.replace('.scss', '.css')])
+ result = subprocess.run(
+ ['sassc', '-mauto', filename, filename.replace('.scss', '.css')],
+ capture_output=True)
+ sys.stdout.write(result.stdout.decode('utf-8'))
+ sys.stderr.write(result.stderr.decode('utf-8'))
+ 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.decode('utf-8').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])