public TokenizedSassPath(StyleSheetResult styleResult) { StyleResult = styleResult; VirtualPath = styleResult.Path; Extension = styleResult.Extension.EmptyNull(); FileName = Path.GetFileName(styleResult.Path); FileNameWithoutExtension = FileName.Substring(0, FileName.Length - Extension.Length); Dir = VirtualPath.Substring(0, VirtualPath.Length - FileName.Length); }
/// <summary> /// Checks last path existence /// </summary> /// <returns>true = does exist, no need to check | false = not checked yet</returns> public bool Check(StyleSheetResult styleResult, out TokenizedSassPath path) { path = new TokenizedSassPath(styleResult); var state = _state.GetState(); if (state.Count == 0) { return(false); } var currentPath = path; var lastPath = _state.GetState().Peek(); if (currentPath.Extension.IsEmpty()) { // We dont't allow extension-less Sass files, so no need to check. return(true); } if (lastPath.Dir != currentPath.Dir) { return(false); } if (currentPath.StyleResult.IsBaseImport && lastPath.StyleResult.IsBaseImport && currentPath.FileName == lastPath.FileName) { return(true); } if (currentPath.StyleResult.IsModuleImports && lastPath.StyleResult.IsModuleImports) { return(true); } if (currentPath.StyleResult.IsThemeVars && lastPath.StyleResult.IsThemeVars) { return(true); } // slick.scss.(scss|sass|css) > slick.scss if (Path.GetExtension(currentPath.FileNameWithoutExtension) == ".scss") { return(true); } // slick.(sass|css) > slick.scss if (!currentPath.StyleResult.IsBaseImport && _styleExtensions.Contains(currentPath.Extension) && currentPath.FileNameWithoutExtension == lastPath.FileNameWithoutExtension) { return(true); } // _slick.scss > slick.scss if (currentPath.FileName.StartsWith("_")) { if (currentPath.FileName.Substring(1) == lastPath.FileName) { return(true); } } // slick.(scss|sass|css) > _slick.scss if (lastPath.FileNameWithoutExtension.StartsWith("_")) { if (lastPath.FileNameWithoutExtension == "_" + currentPath.FileNameWithoutExtension) { return(true); } } return(false); }