Example #1
0
        //This method starts the nw.exe file.
        /// <summary>
        /// Starts the NW.js compiler.
        /// </summary>
        /// <param name="index">The index in the list.</param>
        public void CompileFile(int index)
        {
            CompilerUtilities.RecordToLog("Setting up the compiler...", 3);
            //Removing the JavaScript extension. Needed to place our own File Extension.
            //Setting up the compiler by throwing in two arguments.
            //The first bit (the one with the file variable) is the source.
            //The second bit (the one with the fileBuffer variable) makes the final file.
            CompilerInfo.Value.Arguments = "\"" + FileMap[index] + "\" \"" +
                                           FileMap[index].Replace(".js", "." + FileExtension, StringComparison.Ordinal) + "\"";
            //Making sure not to show the nwjc window. That program doesn't show anything of usefulness.
            CompilerInfo.Value.CreateNoWindow = true;
            CompilerInfo.Value.WindowStyle    = ProcessWindowStyle.Hidden;
            //Run the compiler.
            CompilerUtilities.RecordToLog($"nwjc processing the file {FileMap[index]}...", 3);
            Process.Start(CompilerInfo.Value)?.WaitForExit();

            //If the user asked to remove the JS files, delete them.
            if (RemoveSourceCodeAfterCompiling)
            {
                CompilerUtilities.RecordToLog($"Removing the file {FileMap[index]}...", 3);
                File.Delete(FileMap[index]);
            }
        }