Commits

Gael Pasgrimaud committed b659276

better binary detection. allow to compile a single file

Comments (0)

Files changed (1)

js/lesscss/__init__.py

     if 'LESSC' in os.environ:
         lessc = os.path.abspath(os.environ['LESSC'])
     if lessc is None or not isfile(lessc):
+        for path in ('bin/lessc', '/usr/bin/lessc', '/usr/local/bin/lessc'):
+            if isfile(path):
+                lessc = path
+                break
+    if lessc is None or not isfile(lessc):
         for path in (('node_modules', os.path.expanduser('~/.node_modules'))):
             path = os.path.join(path, 'less', 'bin', 'lessc')
             if isfile(path):
                 lessc = path
+                break
     if not lessc:
         lessc = 'less'
 
         args = ['.']
 
     for arg in args:
-        for root, dirnames, filenames in os.walk(arg):
-            for filename in filenames:
-                if filename.endswith('.less'):
-                    in_path = os.path.join(root, filename)
-                    print in_path
-                    out_path = lessc(in_path, '-x')
-                    print in_path, '->', out_path
+        if os.path.isfile(arg):
+            filename = os.path.abspath(arg)
+            if filename.endswith('.less'):
+                in_path = filename
+                out_path = lessc(in_path, '-x')
+                print in_path, '->', out_path
+        else:
+            for root, dirnames, filenames in os.walk(arg):
+                for filename in filenames:
+                    if filename.endswith('.less'):
+                        in_path = os.path.join(root, filename)
+                        print in_path
+                        out_path = lessc(in_path, '-x')
+                        print in_path, '->', out_path