Exemple #1
0
        private static void TryBowerInstall(this Document document, OutputWindowWriter windowWriter)
        {
            lock (bowerStartingLock)
            {
                if (!_bowerInstallRunning)
                {
                    windowWriter.Show();
                    windowWriter.WriteLine("--- Bower install started ---");
                    System.Threading.Tasks.Task.Run(() =>
                    {
                        try
                        {
                            NodePackageUtils.RunBowerInstall(document.Path,
                                                             (sender, args) => windowWriter.WriteLine(args.Data),
                                                             (sender, args) => windowWriter.WriteLine(args.Data)
                                                             );
                        }
                        catch (Exception e)
                        {
                            windowWriter.WriteLine(e.Message);
                        }

                        lock (bowerRunningLock)
                        {
                            _bowerInstallRunning = false;
                        }
                        windowWriter.WriteLine("--- Bower install complete ---");
                    });
                    lock (bowerRunningLock)
                    {
                        _bowerInstallRunning = true;
                    }
                }
            }
        }
Exemple #2
0
        public static void TryRunNpmInstall(this Document document, OutputWindowWriter windowWriter)
        {
            lock (NpmStartingLock)
            {
                if (_npmInstallRunning)
                {
                    return;
                }
                windowWriter.Show();
                windowWriter.WriteLine("--- NPM install started ---");
                Task.Run(() =>
                {
                    try
                    {
                        NodePackageUtils.RunNpmInstall(document.Path,
                                                       (sender, args) =>
                        {
                            if (string.IsNullOrEmpty(args.Data))
                            {
                                return;
                            }
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            windowWriter.WriteLine(s);
                        },
                                                       (sender, args) =>
                        {
                            if (string.IsNullOrEmpty(args.Data))
                            {
                                return;
                            }
                            string s = Regex.Replace(args.Data, @"[^\u0000-\u007F]", string.Empty);
                            windowWriter.WriteLine(s);
                        });
                    }
                    catch (Exception e)
                    {
                        windowWriter.WriteLine(e.Message);
                    }

                    lock (NpmRunningLock)
                    {
                        _npmInstallRunning = false;
                    }
                    windowWriter.WriteLine("--- NPM install complete ---");
                });
                lock (NpmRunningLock)
                {
                    _npmInstallRunning = true;
                }
            }
        }
Exemple #3
0
        private static void BowerDocumentHandler(Document document, OutputWindowWriter windowWriter)
        {
            if (document.IsBowerUpdateDisabled())
            {
                return;
            }

            _hasBowerInstalled = _hasBowerInstalled ? _hasBowerInstalled : NodePackageUtils.HasBowerOnPath();

            if (!_hasBowerInstalled)
            {
                windowWriter.Show();
                windowWriter.WriteLine(
                    "Bower Installation not detected. Run npm install bower -g to install if Node.js/NPM already installed.");
                return;
            }
            document.TryBowerInstall(windowWriter);
        }
Exemple #4
0
        private static void NpmDocumentHandler(Document document, OutputWindowWriter windowWriter)
        {
            if (document.IsNpmUpdateDisable() || MajorVisualStudioVersion == 14 || (MajorVisualStudioVersion == 12 && ExtensionManager.HasExtension("Package Intellisense")))
            {
                return;
            }

            _hasNpmInstalled = _hasNpmInstalled
                ? _hasNpmInstalled
                : NodePackageUtils.TryRegisterNpmFromDefaultLocation();

            if (!_hasNpmInstalled)
            {
                windowWriter.Show();
                windowWriter.WriteLine("Node.js Installation not detected. Visit http://nodejs.org/ to download.");
                return;
            }
            document.TryRunNpmInstall(windowWriter);
        }
        private static void NpmDocumentHandler(Document document, OutputWindowWriter windowWriter)
        {
            if (document.IsNpmUpdateDisable())
            {
                return;
            }

            _hasNpmInstalled = _hasNpmInstalled
                ? _hasNpmInstalled
                : NodePackageUtils.TryRegisterNpmFromDefaultLocation();

            if (!_hasNpmInstalled)
            {
                windowWriter.Show();
                windowWriter.WriteLine("Node.js Installation not detected. Visit http://nodejs.org/ to download.");
                return;
            }
            document.TryRunNpmInstall(windowWriter);
        }
Exemple #6
0
        public static void HandleBowerPackageUpdate(this Document document, OutputWindowWriter windowWriter)
        {
            string path = document.GetProjectPath();

            //If bower.json and is at the root of the project
            if (document.Name.EqualsIgnoreCase("bower.json") && document.Path.EqualsIgnoreCase(path))
            {
                if (document.IsBowerUpdateDisabled())
                {
                    return;
                }

                hasBowerInstalled = hasBowerInstalled ? hasBowerInstalled : NodePackageUtils.HasBowerOnPath();

                if (!hasBowerInstalled)
                {
                    windowWriter.Show();
                    windowWriter.WriteLine("Bower Installation not detected. Run npm install bower -g to install if Node.js/NPM already installed.");
                    return;
                }
                document.TryBowerInstall(windowWriter);
            }
        }
Exemple #7
0
        public static void HandleNpmPackageUpdate(this Document document, OutputWindowWriter windowWriter)
        {
            string path = document.GetProjectPath();

            //If package.json and is at the root of the project
            if (document.Name.EqualsIgnoreCase("package.json") && document.Path.EqualsIgnoreCase(path))
            {
                if (document.IsNpmUpdateDisable())
                {
                    return;
                }

                hasNpmInstalled = hasNpmInstalled ? hasNpmInstalled : NodePackageUtils.TryRegisterNpmFromDefaultLocation();

                if (!hasNpmInstalled)
                {
                    windowWriter.Show();
                    windowWriter.WriteLine("Node.js Installation not detected. Visit http://nodejs.org/ to download.");
                    return;
                }
                document.TryRunNpmInstall(windowWriter);
            }
        }