Example #1
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                NpmRebuildSettings settings = null;

                // When
                var result = Record.Exception(() => settings.AddScopedPackage("foo", "@bar"));

                // Then
                result.IsArgumentNullException("settings");
            }
Example #2
0
            public void Should_Throw_If_Package_Is_Null()
            {
                // Given
                var settings = new NpmRebuildSettings();

                // When
                var result = Record.Exception(() => settings.AddScopedPackage(null, "@bar"));

                // Then
                result.IsArgumentNullException("packageName");
            }
Example #3
0
            public void Should_Throw_If_Package_Is_Empty()
            {
                // Given
                var settings = new NpmRebuildSettings();

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

                // Then
                result.IsArgumentNullException("packageName");
            }
Example #4
0
            public void Should_Throw_If_Scope_Does_Not_Start_With_At()
            {
                // Given
                var settings = new NpmRebuildSettings();

                // When
                var result = Record.Exception(() => settings.AddScopedPackage("foo", "bar"));

                // Then
                result.IsArgumentException("scope");
            }
Example #5
0
        public static void NpmRebuild(this ICakeContext context, Action <NpmRebuildSettings> configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var settings = new NpmRebuildSettings();

            configurator.Invoke(settings);
            context.NpmRebuild(settings);
        }
Example #6
0
            public void Should_Add_Package()
            {
                // Given
                var settings    = new NpmRebuildSettings();
                var packageName = "foo";

                // When
                settings.AddPackage(packageName);

                // Then
                settings.Packages.Count.ShouldBe(1);
                settings.Packages.ShouldContain(packageName);
            }
Example #7
0
            public void Should_Add_Package_If_Scope_Is_WhiteSpace()
            {
                // Given
                var settings    = new NpmRebuildSettings();
                var packageName = "foo";
                var scope       = " ";

                // When
                settings.AddScopedPackage(packageName, scope);

                // Then
                settings.Packages.Count.ShouldBe(1);
                settings.Packages.ShouldContain(packageName);
            }
Example #8
0
        public static void NpmRebuild(this ICakeContext context, NpmRebuildSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

            AddinInformation.LogVersionInformation(context.Log);
            var rebuilder = new NpmRebuilder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);

            rebuilder.Rebuild(settings);
        }
Example #9
0
        public static void NpmRebuild(this ICakeContext context, params string[] packages)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var settings = new NpmRebuildSettings();

            foreach (var packageName in packages)
            {
                if (!string.IsNullOrWhiteSpace(packageName))
                {
                    settings.AddPackage(packageName);
                }
            }

            context.NpmRebuild(settings);
        }