Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to issue #61 regarding relative file paths not resolving correctly #62

Merged
merged 1 commit into from
Jul 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public override List<Bundle> ParseConfigs()
var processor = new ScriptProcessor(relativePath, fileText, Configuration);
processor.Process();
var result = processor.ProcessedString;
var dependencies = processor.Dependencies.Select(r => this.ResolvePhysicalPath(r)).Where(r => r != null).Distinct().ToList();
var fileDirectory = new FileInfo(file).DirectoryName;
var dependencies = processor.Dependencies.Select(r => this.ResolvePhysicalPath(r, fileDirectory)).Where(r => r != null).Distinct().ToList();
tempFileList.Add(new RequireFile
{
Name = file,
Expand Down
7 changes: 6 additions & 1 deletion RequireJsNet.Compressor/RequireProcessing/ConfigProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal abstract class ConfigProcessor

public abstract List<Bundle> ParseConfigs();

protected string ResolvePhysicalPath(string relativePath)
protected string ResolvePhysicalPath(string relativePath, string directory = "")
{
string entry = this.EntryPoint;
if (!string.IsNullOrEmpty(EntryOverride))
Expand All @@ -52,6 +52,11 @@ protected string ResolvePhysicalPath(string relativePath)
relativePath = relativePath.Substring(1);
}

if (relativePath.StartsWith("./") && !string.IsNullOrEmpty(directory))
{
relativePath = directory + "/" + relativePath.Substring(2);
}

string filePath;

try
Expand Down