예제 #1
0
        public IEnumerable<string> Scan(Build build)
        {
            if (!Directory.Exists(BuildFolder))
            {
                // Need to build everything.
                return QuiFiles;
            }

            Build previousBuild = new Build(BuildFolder);
            previousBuild.AddExistingFiles();

            List<string> quiFilesToCompile = new List<string>();
            foreach (string quiFile in QuiFiles)
            {
                BuildUnit previousBuildUnit;
                bool found = previousBuild.GetCorrespondingBuildUnit(quiFile, out previousBuildUnit);
                if (found && !RequiresCompilation(quiFile, previousBuildUnit))
                {
                    // Up to date -- add to current build as is.
                    build.Add(previousBuildUnit);
                }
                else
                {
                    // Need to compile.
                    quiFilesToCompile.Add(quiFile);
                }
            }

            return quiFilesToCompile;
        }
예제 #2
0
        public void Typical()
        {
            string[] files = {
                                        "Class.SuperClass.js",
                                        "Foo.UnknownSuperClass.js",
                                        "NoSuperClass.js",
                                        "Subclass.Class.js",
                                        "SuperClass.js"
                                   };

            Build build = new Build();
            foreach (BuildUnit unit in files.Select(file => new BuildUnit(file)))
            {
                build.Add(unit);
            }

            string[] expected = {
                                        "Foo.UnknownSuperClass.js",
                                        "NoSuperClass.js",
                                        "SuperClass.js",
                                        "Class.SuperClass.js",
                                        "Subclass.Class.js"
                                    };

            BuildUnit[] sortedBuildFiles = build.SortBuildUnits().ToArray();
            for (int i = 0; i < sortedBuildFiles.Count(); i++)
            {
                Assert.AreEqual(expected[i], sortedBuildFiles[i].JsFileName);
            }
        }
예제 #3
0
        /// <summary>
        /// Compile the given Quick markup files.
        /// Return true if successful, false if there were errors.
        /// </summary>
        /// <remarks>
        /// The compiled JS and CSS files are returned in the properties
        /// of the corresponding name.
        /// </remarks>
        public bool Compile(IEnumerable<string> quiFiles, Build currentBuild)
        {
            if (!Directory.Exists(BuildFolder))
            {
                Directory.CreateDirectory(BuildFolder);
            }

            bool batchSuccess = true;
            foreach (string quiFile in quiFiles)
            {
                BuildUnit buildUnit;
                bool fileSuccess = Compile(quiFile, out buildUnit);
                if (fileSuccess)
                {
                    currentBuild.Add(buildUnit);
                }
                else
                {
                    batchSuccess = false;
                }
            }

            return batchSuccess;
        }