Skip to content

Commit f3b569d

Browse files
Supporting partials with an underscore
Fixed #184 Fixed #185
1 parent 445bb09 commit f3b569d

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

src/WebCompiler/Config/ConfigFileProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void DeleteOutputFiles(string configFile)
7979
/// <summary>
8080
/// Compiles all configs with the same input file extension as the specified sourceFile
8181
/// </summary>
82-
public IEnumerable<CompilerResult> SourceFileChanged(string configFile,
82+
public IEnumerable<CompilerResult> SourceFileChanged(string configFile,
8383
string sourceFile,
8484
string projectPath)
8585
{
@@ -124,7 +124,7 @@ private IEnumerable<CompilerResult> SourceFileChanged(string configFile,
124124
foreach (var file in dependencies[key].DependentFiles.ToArray())
125125
{
126126
if (!compiledFiles.Contains(file.ToLowerInvariant()))
127-
SourceFileChanged(configFile, file, projectPath, compiledFiles);
127+
list.AddRange(SourceFileChanged(configFile, file, projectPath, compiledFiles));
128128
}
129129
}
130130
}

src/WebCompiler/Dependencies/SassDependencyResolver.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void UpdateFileDependencies(string path)
2929
if (this.Dependencies != null)
3030
{
3131
path = path.ToLowerInvariant();
32-
32+
3333
if (!Dependencies.ContainsKey(path))
3434
Dependencies[path] = new Dependencies();
3535

@@ -65,6 +65,19 @@ public override void UpdateFileDependencies(string path)
6565

6666
var dependencyFilePath = importedfile.FullName.ToLowerInvariant();
6767

68+
if (!File.Exists(dependencyFilePath))
69+
{
70+
// Trim leading underscore to support Sass partials
71+
var dir = Path.GetDirectoryName(dependencyFilePath);
72+
var fileName = Path.GetFileName(dependencyFilePath);
73+
var cleanPath = Path.Combine(dir, "_" + fileName);
74+
75+
if (!File.Exists(cleanPath))
76+
continue;
77+
78+
dependencyFilePath = cleanPath;
79+
}
80+
6881
if (!Dependencies[path].DependentOn.Contains(dependencyFilePath))
6982
Dependencies[path].DependentOn.Add(dependencyFilePath);
7083

src/WebCompilerTest/Compile/ScssTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public void CompileScssError()
5252
[TestMethod, TestCategory("SCSS")]
5353
public void AssociateExtensionSourceFileChangedTest()
5454
{
55-
var result = _processor.SourceFileChanged("../../artifacts/scssconfig.json","scss/test.scss", null);
56-
Assert.AreEqual(2, result.Count<CompilerResult>());
55+
var result = _processor.SourceFileChanged(new FileInfo("../../artifacts/scssconfig.json").FullName,new FileInfo( "../../artifacts/scss/_variables.scss").FullName, new DirectoryInfo("../../artifacts/").FullName);
56+
Assert.AreEqual(1, result.Count<CompilerResult>());
57+
Assert.IsTrue(File.Exists("../../artifacts/scss/test.css"));
5758
}
5859

5960
[TestMethod, TestCategory("SCSS")]

src/WebCompilerTest/WebCompilerTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<None Include="artifacts\scss\error.scss" />
106106
<None Include="artifacts\scss\sub\relative.scss" />
107107
<None Include="artifacts\scss\test.scss" />
108-
<None Include="artifacts\scss\variables.scss" />
108+
<None Include="artifacts\scss\_variables.scss" />
109109
<None Include="artifacts\less\error.less" />
110110
<None Include="artifacts\less\test.less" />
111111
<None Include="artifacts\less\variables.less" />

src/WebCompilerTest/artifacts/less/test.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import (reference) "variables.less";
1+
@import (reference) "../less/variables.less";
22
@colorpicker-path: sub;
33

44
/*! important comment*/
File renamed without changes.

0 commit comments

Comments
 (0)