TransformDirectory() public method

public TransformDirectory ( string path, Environment targetEnvironment, bool deleteTemplate = true ) : int
path string
targetEnvironment Environment
deleteTemplate bool
return int
        protected override void ProcessRecord()
        {
            LogManager.LogFactory = new PowerShellCommandLineLogFactory();
            Log = LogManager.GetLogger(typeof (InvokeDirectoryTransform));

            try
            {
                // TODO: make that nice, i'm in hurry right know :)
                EnvironmentProvider envProvider = null;

                envProvider = string.IsNullOrEmpty(Environment) ? new EnvironmentProvider() : new EnvironmentProvider(Directory);

                var templateEngine = new TemplateEngine();

                Environment env = !string.IsNullOrEmpty(Environment) ? envProvider.GetEnvironment(Environment) : envProvider.GetEnvironmentFromFile(EnvironmentFile);

                this.LoadAesKey();

                if (string.IsNullOrEmpty(this.aesKey) == false)
                {
                    env.DecryptVariables(this.aesKey);
                }

                templateEngine.TransformDirectory(Directory, env, false);
            }
            catch (DirectoryNotFoundException)
            {
                Log.Warn(".powerdeploy folder not found for " + Directory + "!");
            }
            catch (FileNotFoundException exception)
            {
                Log.Error(exception.Message);
            }
        }
        public override bool Execute()
        {
            LogManager.LogFactory = new BuildLogFactory(Log);

            Log.LogCommandLine("Transform all project files within the current solution...");

            try
            {
                var envProvider = new EnvironmentProvider(Directory);

                var templateEngine = new TemplateEngine();
                templateEngine.TransformDirectory(Directory, envProvider.GetEnvironment(Environment));
            }
            catch (DirectoryNotFoundException)
            {
                Log.LogError(".powerdeploy folder not found for project " + Directory + "! :(");
                return false;
            }
            catch (FileNotFoundException exception)
            {
                Log.LogError(exception.Message);
                return false;
            }

            return true;
        }
        public void Transform_Read_Only_File()
        {
            var mock = new Mock<IEnvironmentSerializer>();
            mock.Setup(provider => provider.Deserialize("unit")).Returns(GetUnitEnvironment());

            var target = new TemplateEngine();
            using (var dir = new TestFolder())
            {
                dir.AddFile("read-only.template.txt", "whatever: ${var1}");
                dir.AddFile("read-only.txt", "will be transformed").SetReadOnly();

                // before the bugfix: this threw a Exception because the file was ReadOnly
                target.TransformDirectory(dir.DirectoryInfo.FullName, GetUnitEnvironment());

                Assert.AreNotEqual("will be transformed", dir.ReadFile("read-only.txt"));
            }
        }