Beispiel #1
0
        public void Can_find_sass_files_within_folder()
        {
            // Arrange
            var folder = Sample.DirectoryName;

            // Act
            var result = SassCompiler.GetSassFiles(folder);

            // Assert
            result.ShouldNotBeEmpty();
            result.ShouldAllBe(x => x.EndsWith(".scss"));
            result.ShouldAllBe(x => Path.GetFileName(x).StartsWith('_') == false);
        }
Beispiel #2
0
        public bool Execute()
        {
            if (string.IsNullOrEmpty(ProjectDirectory))
            {
                ProjectDirectory = Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode);
            }
            if (!Directory.Exists(ProjectDirectory))
            {
                throw new DirectoryNotFoundException($"Could not find directory at '{ProjectDirectory}'.");
            }

            NodeJS.Install((message, _, __) =>
            {
                Message($"{nameof(CompileSassFiles)}: {message}", MessageImportance.High);
            });

            var options = new CompilerOptions
            {
                Minify             = Minify,
                OutputDirectory    = OutputDirectory,
                AddSourceComments  = AddSourceComments,
                GenerateSourceMaps = GenerateSourceMaps,
                SourceMapDirectory = SourceMapDirectory,
                ConfigurationFile  = (File.Exists(OptionsFile) ? OptionsFile : null)
            };

            int failures = 0;

            foreach (string sassFile in SassCompiler.GetSassFiles(ProjectDirectory))
            {
                CompilerResult result = SassCompiler.Compile(sassFile, options);

                foreach (CompilerError err in result.Errors)
                {
                    LogError(err);
                }
                if (result.Success)
                {
                    LogResult(result);
                }
                else
                {
                    failures++;
                }
            }

            return(failures == 0);
        }