예제 #1
0
 protected override async Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
 {
     if (!NodeProcess.IsReadyToExecute())
     {
         await NodeProcess.EnsurePackageInstalled();
     }
 }
예제 #2
0
        private static async Tasks.Task <bool> CompileSingleFileAsync(CompilerOptions options)
        {
            try
            {
                VsHelpers.CheckFileOutOfSourceControl(options.OutputFilePath);

                if (options.SourceMap)
                {
                    VsHelpers.CheckFileOutOfSourceControl(options.OutputFilePath + ".map");
                }

                CompilerResult result = await NodeProcess.ExecuteProcess(options);

                Logger.Log($"{result.Arguments}");

                if (result.HasError)
                {
                    Logger.Log(result.Error);
                    VsHelpers.WriteStatus($"Error compiling LESS file. See Output Window for details");
                }
                else
                {
                    AddFilesToProject(options);
                    Minify(options);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                VsHelpers.WriteStatus($"Error compiling LESS file. See Output Window for details");
                return(false);
            }
        }
예제 #3
0
        private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk || !_project.IsLessCompilationEnabled())
            {
                return;
            }

            if (NodeProcess.IsInstalling)
            {
                VsHelpers.WriteStatus("The LESS compiler is being installed. Please try again in a few seconds...");
            }
            else if (NodeProcess.IsReadyToExecute())
            {
                CompilerOptions options = await CompilerOptions.Parse(e.FilePath, _view.TextBuffer.CurrentSnapshot.GetText());

                if (_view.Properties.TryGetProperty(typeof(LessAdornment), out LessAdornment adornment))
                {
                    await adornment.Update(options);
                }

                if (options == null || !_project.SupportsCompilation() || !_project.IsLessCompilationEnabled())
                {
                    return;
                }

                await LessCatalog.UpdateFile(_project, options);

                if (await LessCatalog.EnsureCatalog(_project))
                {
                    await CompilerService.CompileAsync(options, _project);
                }
            }
        }
예제 #4
0
        private async Tasks.Task Execute()
        {
            if (!NodeProcess.IsReadyToExecute())
            {
                return;
            }

            var solution = (IVsSolution)ServiceProvider.GetService(typeof(SVsSolution));
            IEnumerable <IVsHierarchy> hierarchies = GetProjectsInSolution(solution, __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION);

            foreach (IVsHierarchy hierarchy in hierarchies)
            {
                Project project = GetDTEProject(hierarchy);

                if (project.SupportsCompilation() && project.IsLessCompilationEnabled())
                {
                    if (await LessCatalog.EnsureCatalog(project))
                    {
                        await CompilerService.CompileProjectAsync(project);
                    }
                }
            }
        }