예제 #1
0
        public static CompilerResult Run(Configuration.CompilerOptions options, string currentDirectory = default)
        {
            string scriptPath = Path.Combine(NodeJS.InstallationDirectory, "compiler.js");

            if (!File.Exists(scriptPath))
            {
                throw new FileNotFoundException($"Could not find file at '{scriptPath}'.");
            }

            long   start = System.DateTime.Now.Ticks;
            string cwd   = (Path.GetDirectoryName(options.ConfigurationFile) ?? currentDirectory);

            using (Process node = NodeJS.Execute($"/c node \"{scriptPath}\" {options.ToArgs()}", cwd))
            {
                GetOutput(node.StandardOutput, cwd, out string[] sourceFiles, out string[] generatedFiles);

                return(new CompilerResult(
                           (node.ExitCode == 0),
                           GetErrors(node.StandardError).ToArray(),
                           sourceFiles,
                           generatedFiles,
                           System.TimeSpan.FromTicks(System.DateTime.Now.Ticks - start)
                           ));
            }
        }
예제 #2
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            vs = (EnvDTE.DTE) await GetServiceAsync(typeof(EnvDTE.DTE));

            GetDialogPage(typeof(ConfigurationPage));

            var commandService = (OleMenuCommandService) await GetServiceAsync(typeof(IMenuCommandService));

            if (commandService != null)
            {
                commandService.AddCommand(new OleMenuCommand(OnGotoConfigurationPageCommandInvoked, new CommandID(Symbol.CmdSet.Guid, Symbol.CmdSet.GotoConfigurationPageCommandId)));
                commandService.AddCommand(new OleMenuCommand(OnConfigureCompileOnBuildCommandInvoked, new CommandID(Symbol.CmdSet.Guid, Symbol.CmdSet.ConfigureCompileOnBuildCommandId)));
            }

            var outputWindow = (IVsOutputWindow) await GetServiceAsync(typeof(SVsOutputWindow));

            if (outputWindow != null)
            {
                var guid = new Guid("3b0eb69d-dbb6-495b-9e72-f8967f02bd23");
                outputWindow.CreatePane(ref guid, Symbol.Name, 1, 1);
                outputWindow.GetPane(ref guid, out IVsOutputWindowPane pane);

                _watcher = new TypescriptWatcher(this, pane);
                await NodeJS.InstallAsync((message, counter, goal) =>
                {
                    progress?.Report(new ServiceProgressData(message, message, counter, goal));
                    System.Diagnostics.Debug.WriteLine(message);
                    pane.Writeline(message);

                    if (counter >= goal)
                    {
                        _watcher.Start();
                    }
                });
            }
        }