private static IEnumerable <string> CompileImpl(ILessEngine engine, string inputFilePath, string outputFilePath) { engine = new FixImportPathDecorator(engine); var currentDir = Directory.GetCurrentDirectory(); try { Console.WriteLine("{0} -> {1}", inputFilePath, outputFilePath); var directoryPath = Path.GetDirectoryName(inputFilePath); var fileReader = new dotless.Core.Input.FileReader(); var source = fileReader.GetFileContents(inputFilePath); Directory.SetCurrentDirectory(directoryPath); var css = engine.TransformToCss(source, inputFilePath); File.WriteAllText(outputFilePath, css); if (!engine.LastTransformationSuccessful) { returnCode = -5; Console.WriteLine(); Console.WriteLine("[Done - Failed]"); } else { Console.WriteLine("[Done]"); } var files = new List <string>(); files.Add(inputFilePath); foreach (var file in engine.GetImports()) { files.Add(Path.Combine(directoryPath, Path.GetExtension(file))); } engine.ResetImports(); return(files); } catch (IOException ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); returnCode = -2; return(null); } catch (Exception ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); returnCode = -3; return(null); } finally { Directory.SetCurrentDirectory(currentDir); } }
private static IEnumerable<string> CompileImpl(ILessEngine engine, string inputFilePath, string outputFilePath) { engine = new FixImportPathDecorator(engine); var currentDir = Directory.GetCurrentDirectory(); try { Console.WriteLine("{0} -> {1}", inputFilePath, outputFilePath); var directoryPath = Path.GetDirectoryName(inputFilePath); var source = new dotless.Core.Input.FileReader().GetFileContents(inputFilePath); Directory.SetCurrentDirectory(directoryPath); var css = engine.TransformToCss(source, inputFilePath); File.WriteAllText(outputFilePath, css); Console.WriteLine("[Done]"); var files = new List<string>(); files.Add(inputFilePath); foreach (var file in engine.GetImports()) files.Add(Path.Combine(directoryPath, Path.ChangeExtension(file, "less"))); engine.ResetImports(); return files; } catch (IOException) { throw; } catch (Exception ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); return null; } finally { Directory.SetCurrentDirectory(currentDir); } }
private static IEnumerable<string> CompileImpl(ILessEngine engine, string inputFilePath, string outputFilePath) { engine = new FixImportPathDecorator(engine); try { Console.WriteLine("{0} -> {1}", inputFilePath, outputFilePath); var directoryPath = Path.GetDirectoryName(inputFilePath); var fileReader = new dotless.Core.Input.FileReader(); var source = fileReader.GetFileContents(inputFilePath); engine.CurrentDirectory = directoryPath; var watch = new Stopwatch(); watch.Start(); var css = engine.TransformToCss(source, inputFilePath); watch.Stop(); File.WriteAllText(outputFilePath, css); if (!engine.LastTransformationSuccessful) { returnCode = -5; Console.WriteLine(); Console.WriteLine("[Done - Failed]"); } else { Console.WriteLine("[Done in {0}]", watch.Elapsed); } var files = new List<string>(); files.Add(inputFilePath); foreach (var file in engine.GetImports()) files.Add(Path.Combine(directoryPath, Path.GetExtension(file))); engine.ResetImports(); return files; } catch (IOException ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); returnCode = -2; return null; } catch (Exception ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); returnCode = -3; return null; } }
private static IEnumerable<string> CompileImpl(ILessEngine engine, string inputFilePath, string outputFilePath) { engine = new FixImportPathDecorator(engine); var currentDir = Directory.GetCurrentDirectory(); try { Console.WriteLine("{0} -> {1}", inputFilePath, outputFilePath); var directoryPath = Path.GetDirectoryName(inputFilePath); var fileReader = new dotless.Core.Input.FileReader(); var source = fileReader.GetFileContents(inputFilePath); Directory.SetCurrentDirectory(directoryPath); var css = engine.TransformToCss(source, inputFilePath); File.WriteAllText(outputFilePath, css); if (!engine.LastTransformationSuccessful) { returnCode = -5; Console.WriteLine(); Console.WriteLine("[Done - Failed]"); } else { Console.WriteLine("[Done]"); } var files = new List<string>(); files.Add(inputFilePath); foreach (var file in engine.GetImports()) files.Add(Path.Combine(directoryPath, Path.ChangeExtension(file, "less"))); engine.ResetImports(); return files; } <<<<<<< HEAD //catch (IOException) //{ // throw; //} //catch (Exception ex) //{ // Console.WriteLine("[FAILED]"); // Console.WriteLine("Compilation failed: {0}", ex.Message); // Console.WriteLine(ex.StackTrace); // return null; //} ======= catch (IOException) { returnCode = -2; throw; } catch (Exception ex) { Console.WriteLine("[FAILED]"); Console.WriteLine("Compilation failed: {0}", ex.Message); Console.WriteLine(ex.StackTrace); returnCode = -3; return null; } >>>>>>> 57986d4e1b45102058e055468254b85e34a41e98 finally { Directory.SetCurrentDirectory(currentDir); } }