Debian Codegraph @

setup/csslint.py

raw
1 #!/usr/bin/env python
2 # License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
3
4 import os
5 import shutil
6 import subprocess
7
8 from setup import Command
9
10
11 class CSSLint(Command):
12 description = 'Update the bundled copy of stylelint'
13 NAME = 'stylelint-bundle.min.js'
14 DOWNLOAD_URL = 'https://github.com/openstyles/stylelint-bundle.git'
15
16 @property
17 def vendored_file(self):
18 return os.path.join(self.RESOURCES, self.NAME)
19
20 def run(self, opts):
21 self.clean()
22
23 with self.temp_dir() as dl_src:
24 subprocess.check_call(['git', 'clone', '--depth=1', self.DOWNLOAD_URL], cwd=dl_src)
25 src = self.j(dl_src, 'stylelint-bundle')
26 subprocess.check_call(['npm', 'install'], cwd=src)
27 subprocess.check_call(['npm', 'run', 'build'], cwd=src)
28 shutil.copyfile(self.j(src, 'dist', self.NAME), self.vendored_file)
29
30 def clean(self):
31 if os.path.exists(self.vendored_file):
32 os.remove(self.vendored_file)