Beispiel #1
0
        public void Execute(Context context)
        {
            if (!Action.IsApplicable())
            {
                return;
            }
            var pathAndContent = Action.Execute(context);

            Require.NotNullOrEmpty(pathAndContent.ItemInfo.Item);

            //TODO should mapper return absolute path?
            string relativePath = context.PathMapper.MapPath(pathAndContent.ItemInfo, context);
            string path         = context.GetAbsolutePath(relativePath);

            if (File.Exists(path) && File.ReadAllText(path) == pathAndContent.Content)
            {//same content
                context.Tracker.OnFileSkipped(relativePath);
            }
            else
            {//did not exist or has changed
                FileUtils.WriteAllText(path, pathAndContent.Content);
                context.Tracker.OnFileUpdated(relativePath);
            }
        }
Beispiel #2
0
 private static IResult ActionImplStrategy(IOutputAction output, OutputResultData result)
 => output == null
         ? OutputResult.NullResult
         : output.Execute(result);