actually fixed windows scss build

This commit is contained in:
Harvey Tindall 2020-08-04 18:12:18 +01:00
parent a38045cefb
commit 8d265879cc
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
2 changed files with 16 additions and 6 deletions

View File

@ -12,7 +12,13 @@ def runcmd(cmd):
return proc.communicate() return proc.communicate()
local_path = Path(__file__).resolve().parent local_path = Path(__file__).resolve().parent
node_bin = Path(runcmd("npm bin")[0].decode('utf-8').rstrip()) out = runcmd("npm bin")
try:
node_bin = Path(out[0].decode('utf-8').rstrip())
except:
node_bin = Path(out.decode('utf-8').rstrip())
print(f"assuming npm bin directory \"{node_bin}\". Is this correct?") print(f"assuming npm bin directory \"{node_bin}\". Is this correct?")
if input("[yY/nN]: ").lower() == "n": if input("[yY/nN]: ").lower() == "n":
node_bin = local_path.parent / 'node_modules' / '.bin' node_bin = local_path.parent / 'node_modules' / '.bin'
@ -30,7 +36,11 @@ for bsv in [d for d in local_path.iterdir() if 'bs' in d.name]:
precision=6)) precision=6))
if css.exists(): if css.exists():
print(f'{bsv.name}: Compiled.') print(f'{bsv.name}: Compiled.')
runcmd(f'{str((node_bin / "postcss").resolve())} {str(css.resolve())} --replace --use autoprefixer') # postcss only excepts forwards slashes? weird.
cssPath = str(css.resolve())
if os.name == 'nt':
cssPath = cssPath.replace('\\', '/')
runcmd(f'{str((node_bin / "postcss").resolve())} {cssPath} --replace --use autoprefixer')
print(f'{bsv.name}: Prefixed.') print(f'{bsv.name}: Prefixed.')
runcmd(f'{str((node_bin / "cleancss").resolve())} --level 1 --format breakWith=lf --output {str(min_css.resolve())} {str(css.resolve())}') runcmd(f'{str((node_bin / "cleancss").resolve())} --level 1 --format breakWith=lf --output {str(min_css.resolve())} {str(css.resolve())}')
if min_css.exists(): if min_css.exists():

View File

@ -14,12 +14,12 @@ def runcmd(cmd):
print('Installing npm packages') print('Installing npm packages')
if os.name == "nt":
print("Note: npm on windows installs all packages in the root directory, so things might get ugly.")
root_path = Path(__file__).parents[1] root_path = Path(__file__).parents[1]
runcmd(f'npm install --prefix {root_path}') if os.name == 'nt':
root_path /= 'node_modules'
runcmd(f'npm install')
if (root_path / 'node_modules' / 'cleancss').exists(): if (root_path / 'node_modules' / 'cleancss').exists():
print(f'Installed successfully in {str((root_path / "node_modules").resolve())}.') print(f'Installed successfully in {str((root_path / "node_modules").resolve())}.')