public static RequestFileCacheMetadata SetES5FileInCache(RequestFileMetadata file) { if (file == null) { throw new NullReferenceException(nameof(file)); } string es5FilePath = GetES5FilePath(file.SourcePath); string sourceES5Path = Path.GetDirectoryName(es5FilePath); if (!Directory.Exists(sourceES5Path)) { Directory.CreateDirectory(sourceES5Path); } //Should behave as an overwrite behavior if applicable WriteTextToFile(es5FilePath, file.SourceCheckSum, file.ES5Content); return(AddFileCacheEntry(file.SourcePath, es5FilePath, file.SourceCheckSum)); }
private RequestFileMetadata ES5Convert(RequestFileMetadata source) { RequestFileMetadata destination = null; try { //Transpile code to ES5 for IE11 source.ES5Content = BabelHelper.Transform(source.SourceContent, Path.GetFileName(source.SourcePath)); //Minify with AjaxMin (we don't want an additional external tool with NPM or else for managing this //kind of thing here... source.ES5Content = Uglify.Js(source.ES5Content).Code; destination = source; } catch (Exception ex) { LogHelper.LogError($"On path '{source.SourcePath}': {ex.Message}."); } return(destination); }