Skip to content

Instantly share code, notes, and snippets.

View TanmayDharmaraj's full-sized avatar
🏠
Working from home

Tanmay Dharmaraj TanmayDharmaraj

🏠
Working from home
View GitHub Profile
@TanmayDharmaraj
TanmayDharmaraj / rev-manifest.json
Last active December 20, 2017 06:16
A revision manifest created by gulp-rev
{
"assets/css/site.compiled.css": "assets/css/site-1db21d418d.compiled.css",
"js/site.min.js": "js/site-ff3eec37bc.min.js",
"vendors/vendors.js": "vendors/vendors-ebd24a3d51.js"
}
@TanmayDharmaraj
TanmayDharmaraj / revision.cs
Last active December 20, 2017 06:15
Read manifest JSON and return revised filename created via gulp-rev
public static class Revision
{
public static string Version(string path)
{
if (HttpRuntime.Cache[path] == null)
{
using (StreamReader sr = new StreamReader(HostingEnvironment.MapPath("~/Scripts/rev-manifest.json")))
{
Dictionary<string, string> rev = JsonConvert.DeserializeObject<Dictionary<string, string>>(sr.ReadToEnd());
string revedFile = rev.Where(s => path.Contains(s.Key)).Select(g => g.Value).FirstOrDefault();