processor.setDebug(args.debug)
if args.debug:
processor.setCompiler('lessc')
+ elif M.branch_compare(29, '<'):
+ # Grunt was only introduced for 2.9.
+ processor.setCompiler('recess')
+
processor.compile(theme=args.theme, sheets=args.sheets)
# Setting up watchdog. This code should be improved when we will have more than a compile option.
# Check binaries.
hasErrors = False
- for k in ['git', 'php', 'java', 'recess', 'lessc', 'shifter', 'yuidoc']:
+ for k in ['git', 'php', 'java', 'recess', 'grunt', 'lessc', 'shifter', 'yuidoc']:
path = self.C.get(k)
if not path or not os.path.isfile(path):
print ' The path to \'%s\' is invalid: %s' % (k, path)
"php": "/usr/bin/php",
// Path to Java
"java": "/usr/bin/java",
+ // Path to Grunt
+ "grunt": "/usr/local/bin/grunt",
// Path to recess
"recess": "/usr/local/bin/recess",
// Path to lessc
_M = None
_debug = False
- _compiler = 'recess'
+ _compiler = 'grunt'
def __init__(self, M):
self._M = M
hadErrors = False
+ if self._compiler == 'grunt':
+ sheets = ['moodle']
+
for name in sheets:
sheet = name + '.less'
destSheet = name + '.css'
continue
try:
- if self._compiler == 'recess':
+ if self._compiler == 'grunt':
+ compiler = Grunt(source, os.path.join(source, sheet), os.path.join(dest, destSheet))
+ elif self._compiler == 'recess':
compiler = Recess(source, os.path.join(source, sheet), os.path.join(dest, destSheet))
elif self._compiler == 'lessc':
compiler = Lessc(self.getThemeDir(), os.path.join(source, sheet), os.path.join(dest, destSheet))
self._debug = debug
+class Grunt(Compiler):
+ """Grunt compiler"""
+
+ def execute(self):
+ executable = C.get('grunt')
+ if not executable:
+ raise Exception('Could not find executable path')
+
+ cmd = [executable, 'css']
+
+ (code, out, err) = process(cmd, self._cwd)
+ if code != 0 or len(out) == 0:
+ raise CssCompileFailed('Error during compile')
+
+
class Recess(Compiler):
"""Recess compiler"""
echo " mdk css --compile"
echo ""
-P=`mdk info -v path`
-if [[ -z "$(which recess)" ]]; then
- echo "Recess could not be found. Aborting..."
- exit 1
-fi
-
-DIR="$P/theme/bootstrapbase/less"
-if [[ ! -d "$DIR" ]]; then
- echo "Could not find theme/boostrapbase. Aborting..."
- exit 2
-fi
-
-echo "Compiling theme/bootstrapbase CSS"
-cd "$DIR"
-recess --compile --compress moodle.less > ../style/moodle.css
-recess --compile --compress editor.less > ../style/editor.css
+mdk css --compile