示例#1
0
        public override void Execute(IAbsolutePath path, AbsoluteFilePath project, IEnumerable <string> arguments)
        {
            var file = path as AbsoluteFilePath;

            if (file == null)
            {
                throw new ImportFailed("'" + path + "' does not appear to be a file");
            }

            var outputDir = project.ContainingDirectory.Combine(SketchImportUtils.OutputDirName);

            try
            {
                Directory.CreateDirectory(outputDir.NativePath);
            }
            catch (Exception e)
            {
                _reportLogger.Error("Sketch importer error: " + e.Message);
            }

            if (SketchImportUtils.IsSketchFile(file))
            {
                TryConvert(new[] { file.NativePath }, outputDir.NativePath);
            }
            else if (SketchImportUtils.IsSketchFilesFile(file))
            {
                // load sketch file paths from the json-file
                var sketchFiles = SketchImportUtils.MakeAbsolute(
                    SketchImportUtils.SketchFilePaths(SketchImportUtils.SketchListFilePath(project), _reportLogger),
                    project.ContainingDirectory).Select(f => f.NativePath).ToArray();

                TryConvert(sketchFiles, outputDir.NativePath);
            }
        }
示例#2
0
        public void SketchFilePaths_MakePathsAbsolute()
        {
            var relPathFile = Platform.OperatingSystem == OS.Windows ? @"SketchFiles\\File1.sketch" : "SketchFiles/File1.sketch";
            var absPathFile = Platform.OperatingSystem == OS.Windows ? @"C:\\File2.sketch" : @"/File2.sketch";
            var content     = "[\"" + relPathFile + "\",\"" + absPathFile + "\"]";

            File.WriteAllText(_sketchListFile.NativePath, content);


            var report      = Substitute.For <IReport>();
            var fs          = Substitute.For <IFileSystem>();
            var sketchFiles = SketchImportUtils.MakeAbsolute(
                new SketchWatcher(report, fs).SketchFilePaths(_sketchListFile),
                _sketchListFile.ContainingDirectory);

            var expected = new List <AbsoluteFilePath>
            {
                _sketchListFile.ContainingDirectory / "SketchFiles" / new FileName("File1.sketch"),
                AbsoluteFilePath.Parse(absPathFile)
            };

            Assert.That(sketchFiles, Is.EqualTo(expected));
        }