Exemple #1
0
 private void ProcessNpmInstall(string projectPath)
 {
     try
     {
         UpdateStatusMessage("Clearing NPM cache...");
         NodePackageUtils.NpmClearCache(projectPath);
         UpdateStatusMessage("Running NPM install...");
         OutputWindowWriter.WriteLine("--- NPM install started ---");
         NodePackageUtils.RunNpmInstall(projectPath,
                                        (sender, args) =>
         {
             if (!string.IsNullOrEmpty(args.Data))
             {
                 var s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                 OutputWindowWriter.WriteLine(s);
             }
         },
                                        (sender, args) =>
         {
             if (!string.IsNullOrEmpty(args.Data))
             {
                 var s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                 OutputWindowWriter.WriteLine(s);
             }
         }, 600);
         UpdateStatusMessage("Ready");
         StatusBar.Clear();
     }
     catch (Exception exception)
     {
         OutputWindowWriter.WriteLine("An error has occurred during an NPM install");
         OutputWindowWriter.WriteLine("NPM install failed: " + exception.Message);
     }
     OutputWindowWriter.WriteLine("--- NPM install complete ---");
 }
Exemple #2
0
        public void ProjectFinishedGenerating(Project project)
        {
            string projectPath = project.FullName.Substring(0,
                                                            project.FullName.LastIndexOf("\\", StringComparison.Ordinal));

            System.Threading.Tasks.Task.Run(() =>
            {
                StartRequiredPackageInstallations();
                try
                {
                    if (!NodePackageUtils.HasBowerOnPath())
                    {
                        string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                        string npmFolder     = Path.Combine(appDataFolder, "npm");
                        npmFolder.AddToPathEnvironmentVariable();
                    }
                    UpdateStatusMessage("Downloading bower depedencies...");
                    NodePackageUtils.RunBowerInstall(projectPath, (sender, args) =>
                    {
                        if (!string.IsNullOrEmpty(args.Data))
                        {
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            OutputWindowWriter.WriteLine(s);
                        }
                    }, (sender, args) =>
                    {
                        if (!string.IsNullOrEmpty(args.Data))
                        {
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            OutputWindowWriter.WriteLine(s);
                        }
                    });
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Bower install failed: " + exception.Message,
                                    "An error has occurred during a Bower install.",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.DefaultDesktopOnly,
                                    false);
                }
            }).Wait();

            UpdateStatusMessage("Downloading NPM depedencies...");
            OutputWindowWriter.ShowOutputPane(dte);
            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    UpdateStatusMessage("Clearing NPM cache...");
                    NodePackageUtils.NpmClearCache(projectPath);
                    UpdateStatusMessage("Running NPM install...");
                    OutputWindowWriter.WriteLine("--- NPM install started ---");
                    NodePackageUtils.RunNpmInstall(projectPath,
                                                   (sender, args) =>
                    {
                        if (!string.IsNullOrEmpty(args.Data))
                        {
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            OutputWindowWriter.WriteLine(s);
                        }
                    },
                                                   (sender, args) =>
                    {
                        if (!string.IsNullOrEmpty(args.Data))
                        {
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            OutputWindowWriter.WriteLine(s);
                        }
                    }, 600);
                    UpdateStatusMessage("Ready");
                    StatusBar.Clear();
                }
                catch (Exception exception)
                {
                    OutputWindowWriter.WriteLine("An error has occurred during an NPM install");
                    OutputWindowWriter.WriteLine("NPM install failed: " + exception.Message);
                }
                OutputWindowWriter.WriteLine("--- NPM install complete ---");
            });
        }