sassw: let subprocess.run handle text encoding

This commit is contained in:
Frédéric Péters 2019-08-25 18:00:54 +02:00
parent b351f2e8aa
commit e7d34ce082
1 changed files with 5 additions and 4 deletions

View File

@ -25,9 +25,10 @@ def build():
global sources, directories
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'))
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:
@ -35,7 +36,7 @@ def build():
white-space: pre;
font-family: monospace;
content: "%s";
}''' % result.stderr.decode('utf-8').replace('\n', '\\A').replace('"', '\\"'),
}''' % 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']]