Exemple #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");
            }
Exemple #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");
            }
Exemple #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");
            }
Exemple #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");
            }
Exemple #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);
        }
Exemple #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);
            }
Exemple #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);
            }
Exemple #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);
        }
Exemple #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);
        }