public override int OnExecute(CommandLineApplication config)
        {
            if (!File.Exists(this.BundleIndexPath))
            {
                Utils.WriteLine(string.Format(Constants.AdminAppExtensionsBundleNotFoundMessage, this.Name, this.BundlePath, this.BundleName), ConsoleColor.Red);
                return((int)ExitCode.GeneralError);
            }

            if (!Directory.Exists(this.TargetFolder))
            {
                Directory.CreateDirectory(this.TargetFolder);
            }
            else if (File.Exists(Path.Combine(this.TargetFolder, "index.ts")))
            {
                Utils.WriteLine(string.Format(Constants.ResourceExistsMessage, "AdminApp Extension", this.Name, this.TargetFolder), ConsoleColor.Red);
                return((int)ExitCode.GeneralError);
            }

            if (base.OnExecute(config) == 1)
            {
                return((int)ExitCode.GeneralError);
            }

            TsModuleModifier.RegisterExtension(this.BundleIndexPath, this.Name + "Module", this.KebabCaseName);

            return((int)ExitCode.OK);
        }
Ejemplo n.º 2
0
        public void SuccessfullyRegisterNewExtension_When_IndexFileHasNoRegisteredModules()
        {
            FileModifierResult result = TsModuleModifier.RegisterExtension(this.IndexWithoutModulesPath, "TestModule", "test");

            Assert.IsTrue(result.Success);

            var currentState = File.ReadAllText(this.IndexWithoutModulesPath);

            Assert.AreEqual(this._expectedIndexWithoutModules, currentState);
        }