public void DeleteOutputFiles(string bundleFileName)
        {
            var bundles = BundleHandler.GetBundles(bundleFileName);

            foreach (Bundle bundle in bundles)
            {
                var outputFile = bundle.GetAbsoluteOutputFile();
                var minFile    = BundleFileProcessor.GetMinFileName(outputFile);
                var mapFile    = minFile + ".map";

                if (File.Exists(outputFile))
                {
                    File.Delete(outputFile);
                }
                if (File.Exists(minFile))
                {
                    File.Delete(minFile);
                }
                if (File.Exists(mapFile))
                {
                    File.Delete(mapFile);
                }
            }

            Telemetry.TrackEvent("Delete output files");
        }
Ejemplo n.º 2
0
        public static IEnumerable <Bundle> IsFileConfigured(string configFile, string sourceFile)
        {
            List <Bundle> list = new List <Bundle>();

            try
            {
                var    configs = BundleHandler.GetBundles(configFile);
                string folder  = Path.GetDirectoryName(configFile);

                foreach (Bundle bundle in configs)
                {
                    foreach (string input in bundle.GetAbsoluteInputFiles())
                    {
                        if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase) && !list.Contains(bundle))
                        {
                            list.Add(bundle);
                        }
                    }
                }

                return(list);
            }
            catch (Exception)
            {
                return(list);
            }
        }
Ejemplo n.º 3
0
        public void Process(string fileName)
        {
            FileInfo info    = new FileInfo(fileName);
            var      bundles = BundleHandler.GetBundles(fileName);

            foreach (Bundle bundle in bundles)
            {
                ProcessBundle(info.Directory.FullName, bundle);
            }
        }
Ejemplo n.º 4
0
        public void Clean(string fileName, IEnumerable <Bundle> bundles = null)
        {
            FileInfo info = new FileInfo(fileName);

            bundles = bundles ?? BundleHandler.GetBundles(fileName);

            foreach (Bundle bundle in bundles)
            {
                CleanBundle(info.Directory.FullName, bundle);
            }
        }
Ejemplo n.º 5
0
        public override bool Execute()
        {
            try
            {
                FileInfo configFile = new FileInfo(FileName);

                Log.LogMessage(MessageImportance.High, Environment.NewLine + "Bundler: Cleaning output from " + configFile.Name);

                if (!configFile.Exists)
                {
                    Log.LogWarning(configFile.FullName + " does not exist");
                    return(true);
                }

                var bundles = BundleHandler.GetBundles(configFile.FullName);

                if (bundles != null)
                {
                    foreach (Bundle bundle in bundles)
                    {
                        var outputFile = bundle.GetAbsoluteOutputFile();
                        var inputFiles = bundle.GetAbsoluteInputFiles();

                        var minFile  = BundleMinifier.GetMinFileName(outputFile, bundle.MinFileName);
                        var mapFile  = minFile + ".map";
                        var gzipFile = minFile + ".gz";

                        if (!inputFiles.Contains(outputFile))
                        {
                            Deletefile(outputFile);
                        }

                        Deletefile(minFile);
                        Deletefile(mapFile);
                        Deletefile(gzipFile);
                    }

                    Log.LogMessage(MessageImportance.High, "Bundler: Done cleaning output file from " + configFile.Name);

                    return(true);
                }

                Log.LogWarning($"There was an error reading {configFile.Name}");
                return(false);
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                Log.LogErrorFromException(e.InnerException);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool Process(string fileName, IEnumerable <Bundle> bundles = null)
        {
            FileInfo info = new FileInfo(fileName);

            bundles = bundles ?? BundleHandler.GetBundles(fileName);
            bool result = false;

            foreach (Bundle bundle in bundles)
            {
                result |= ProcessBundle(info.Directory.FullName, bundle);
            }

            return(result);
        }
Ejemplo n.º 7
0
        public void SourceFileChanged(string bundleFile, string sourceFile)
        {
            var    bundles          = BundleHandler.GetBundles(bundleFile);
            string bundleFileFolder = Path.GetDirectoryName(bundleFile),
                   sourceFileFolder = Path.GetDirectoryName(sourceFile);

            foreach (Bundle bundle in bundles)
            {
                foreach (string input in bundle.GetAbsoluteInputFiles())
                {
                    if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase) || input.Equals(sourceFileFolder, StringComparison.OrdinalIgnoreCase))
                    {
                        ProcessBundle(bundleFileFolder, bundle);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void SourceFileChanged(string bundleFile, string sourceFile)
        {
            var    bundles          = BundleHandler.GetBundles(bundleFile);
            string bundleFileFolder = Path.GetDirectoryName(bundleFile),
                   sourceFileFolder = Path.GetDirectoryName(sourceFile);

            foreach (Bundle bundle in bundles)
            {
                foreach (string inputFile in bundle.InputFiles)
                {
                    string input = Path.Combine(bundleFileFolder, inputFile.Replace("/", "\\"));

                    if (input.Equals(sourceFile, System.StringComparison.OrdinalIgnoreCase) ||
                        input.Equals(sourceFileFolder, System.StringComparison.OrdinalIgnoreCase))
                    {
                        ProcessBundle(bundleFileFolder, bundle);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private static IEnumerable <Bundle> GetConfigs(string configPath, string file)
        {
            var configs = BundleHandler.GetBundles(configPath);

            if (configs == null || !configs.Any())
            {
                return(null);
            }

            if (file != null)
            {
                if (file.StartsWith("*"))
                {
                    configs = configs.Where(c => Path.GetExtension(c.OutputFileName).Equals(file.Substring(1), StringComparison.OrdinalIgnoreCase));
                }
                else
                {
                    configs = configs.Where(c => c.OutputFileName.Equals(file, StringComparison.OrdinalIgnoreCase));
                }
            }

            return(configs);
        }
Ejemplo n.º 10
0
        public void DeleteOutputFiles(string bundleFileName)
        {
            var bundles = BundleHandler.GetBundles(bundleFileName);

            foreach (Bundle bundle in bundles)
            {
                var outputFile = bundle.GetAbsoluteOutputFile();
                var inputFiles = bundle.GetAbsoluteInputFiles();

                var minFile  = GetMinFileName(outputFile);
                var mapFile  = minFile + ".map";
                var gzipFile = minFile + ".gz";

                if (!inputFiles.Contains(outputFile))
                {
                    if (File.Exists(outputFile))
                    {
                        File.Delete(outputFile);
                    }
                }

                if (File.Exists(minFile))
                {
                    File.Delete(minFile);
                }
                if (File.Exists(mapFile))
                {
                    File.Delete(mapFile);
                }
                if (File.Exists(gzipFile))
                {
                    File.Delete(gzipFile);
                }
            }

            Telemetry.TrackEvent("Delete output files");
        }