Пример #1
0
        internal async System.Threading.Tasks.Task UpdateModules(IList <HierarchyNode> nodes)
        {
            DoPreCommandActions();
            try {
                using (var commander = NpmController.CreateNpmCommander()) {
                    if (nodes.Count == 1 && nodes[0] == this)
                    {
                        await commander.UpdatePackagesAsync();
                    }
                    else
                    {
                        var valid = nodes.OfType <DependencyNode>().Where(CheckValidCommandTarget).ToList();

                        var list = valid.Where(node => node.GetPropertiesObject().IsGlobalInstall).Select(node => node.Package).ToList();
                        if (list.Count > 0)
                        {
                            await commander.UpdateGlobalPackagesAsync(list);
                        }

                        list = valid.Where(node => !node.GetPropertiesObject().IsGlobalInstall).Select(node => node.Package).ToList();
                        if (list.Count > 0)
                        {
                            await commander.UpdatePackagesAsync(list);
                        }
                    }
                }
            } catch (NpmNotFoundException nnfe) {
                ErrorHelper.ReportNpmNotInstalled(null, nnfe);
            } finally {
                AllowCommands();
            }
        }
Пример #2
0
 public async System.Threading.Tasks.Task InstallMissingModules()
 {
     DoPreCommandActions();
     try {
         using (var commander = NpmController.CreateNpmCommander()) {
             await commander.Install();
         }
     } catch (NpmNotFoundException nnfe) {
         ErrorHelper.ReportNpmNotInstalled(null, nnfe);
     } finally {
         AllowCommands();
     }
 }
Пример #3
0
 private async System.Threading.Tasks.Task RunNpmCommand(Func <INpmCommander, System.Threading.Tasks.Task> impl)
 {
     DoPreCommandActions();
     try {
         using (var commander = NpmController.CreateNpmCommander()) {
             await impl(commander);
         }
     } catch (NpmNotFoundException nnfe) {
         ErrorHelper.ReportNpmNotInstalled(null, nnfe);
     } finally {
         AllowCommands();
     }
 }
Пример #4
0
        public async System.Threading.Tasks.Task InstallMissingModule(DependencyNode node)
        {
            if (!CheckValidCommandTarget(node))
            {
                return;
            }

            var root = _npmController.RootPackage;

            if (null == root)
            {
                return;
            }

            var pkgJson = root.PackageJson;

            if (null == pkgJson)
            {
                return;
            }

            var package = node.Package;
            var dep     = root.PackageJson.AllDependencies[package.Name];

            DoPreCommandActions();
            try {
                using (var commander = NpmController.CreateNpmCommander()) {
                    if (node.GetPropertiesObject().IsGlobalInstall)
                    {
                        //  I genuinely can't see a way this would ever happen but, just to be on the safe side...
                        await commander.InstallGlobalPackageByVersionAsync(
                            package.Name,
                            null == dep? "*" : dep.VersionRangeText);
                    }
                    else
                    {
                        await commander.InstallPackageByVersionAsync(
                            package.Name,
                            null == dep? "*" : dep.VersionRangeText,
                            DependencyType.Standard,
                            false);
                    }
                }
            } catch (NpmNotFoundException nnfe) {
                ErrorHelper.ReportNpmNotInstalled(null, nnfe);
            } finally {
                AllowCommands();
            }
        }
Пример #5
0
 public async System.Threading.Tasks.Task UninstallModule(DependencyNode node)
 {
     if (!CheckValidCommandTarget(node))
     {
         return;
     }
     DoPreCommandActions();
     try {
         using (var commander = NpmController.CreateNpmCommander()) {
             if (node.GetPropertiesObject().IsGlobalInstall)
             {
                 await commander.UninstallGlobalPackageAsync(node.Package.Name);
             }
             else
             {
                 await commander.UninstallPackageAsync(node.Package.Name);
             }
         }
     } catch (NpmNotFoundException nnfe) {
         ErrorHelper.ReportNpmNotInstalled(null, nnfe);
     } finally {
         AllowCommands();
     }
 }
Пример #6
0
 public async System.Threading.Tasks.Task UninstallModules()
 {
     DoPreCommandActions();
     try {
         var selected = _projectNode.GetSelectedNodes();
         using (var commander = NpmController.CreateNpmCommander()) {
             foreach (var node in selected.OfType <DependencyNode>().Where(CheckValidCommandTarget))
             {
                 if (node.GetPropertiesObject().IsGlobalInstall)
                 {
                     await commander.UninstallGlobalPackageAsync(node.Package.Name);
                 }
                 else
                 {
                     await commander.UninstallPackageAsync(node.Package.Name);
                 }
             }
         }
     } catch (NpmNotFoundException nnfe) {
         ErrorHelper.ReportNpmNotInstalled(null, nnfe);
     } finally {
         AllowCommands();
     }
 }