Exemple #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);
            }
        }
        public void SketchListFilePathGetsCorrectPath()
        {
            var projectFilePath = _projectRoot / new FileName("Project.unoproj");
            var sketchPath      = SketchImportUtils.SketchListFilePath(projectFilePath);

            Assert.That(sketchPath, Is.EqualTo(_projectRoot / new FileName("Project.sketchFiles")));
        }
        public void SketchListFilePath_OnlyReplacesAtEnd()
        {
            var stupidProjectRoot = AbsoluteDirectoryPath.Parse(Platform.OperatingSystem == OS.Windows ? @"c:\Project.unoproj" : "/Project.unoproj");
            var projectFilePath   = stupidProjectRoot / new FileName("Project.unoproj");
            var sketchPath        = SketchImportUtils.SketchListFilePath(projectFilePath);

            Assert.That(sketchPath, Is.EqualTo(stupidProjectRoot / new FileName("Project.sketchFiles")));
        }
        public void SketchListFilePath_FailsIfDoesntEndWithUnoProj()
        {
            var projectFilePath = _projectRoot / new FileName("Project.unicorn");

            Assert.That(() => SketchImportUtils.SketchListFilePath(projectFilePath), Throws.ArgumentException.With.Message.Contains("does not seem to be a .unoproj"));
        }