Beispiel #1
0
            public void Should_Throw_If_Scope_Does_Not_Start_With_At_Symbol()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings();

                // When
                var result = Record.Exception(() => settings.AddPackage("test", "badscope"));

                // Then
                result.IsArgumentException("scope");
            }
Beispiel #2
0
            public void Should_Add_PackageName_To_Packages()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings();

                // When
                settings.AddPackage("test");

                // Then
                settings.Packages.ShouldContain("test");
            }
Beispiel #3
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                NpmPruneSettings settings = null;

                // When
                var result = Record.Exception(() => settings.AddPackage("test"));

                // Then
                result.IsArgumentNullException("settings");
            }
Beispiel #4
0
            public void Should_Throw_If_PackageName_Is_Null_Or_Whitespace(string packageName)
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings();

                // When
                var result = Record.Exception(() => settings.AddPackage(packageName));

                // Then
                result.IsArgumentNullException("packageName");
            }
Beispiel #5
0
            public void Should_Set_Production_Flag_True_()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings();

                // When
                settings.ForProduction();

                // Then
                settings.Production.ShouldBe(true);
            }
Beispiel #6
0
            public void Should_Set_DryRun_Flag_True_()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings();

                // When
                settings.DryRun();

                // Then
                settings.DryRun.ShouldBe(true);
            }
Beispiel #7
0
            public void Should_Set_Production_Flag_False()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings()
                {
                    Production = true
                };

                // When
                settings.ForProduction(false);

                // Then
                settings.Production.ShouldBe(false);
            }
Beispiel #8
0
            public void Should_Set_Json_Flag_False()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings()
                {
                    Json = true
                };

                // When
                settings.Json(false);

                // Then
                settings.Json.ShouldBe(false);
            }
Beispiel #9
0
            public void Should_Set_DryRun_Flag_False()
            {
                // Given
                NpmPruneSettings settings = new NpmPruneSettings()
                {
                    DryRun = true
                };

                // When
                settings.DryRun(false);

                // Then
                settings.DryRun.ShouldBe(false);
            }
        public static void NpmPrune(this ICakeContext context, Action <NpmPruneSettings> configurator)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var settings = new NpmPruneSettings();

            configurator(settings);
            context.NpmPrune(settings);
        }
        public static void NpmPrune(this ICakeContext context, NpmPruneSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            AddinInformation.LogVersionInformation(context.Log);

            var pruner = new NpmPruneRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);

            pruner.Prune(settings);
        }