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 override bool CanExecute(IAbsolutePath path, AbsoluteFilePath project) { var file = path as AbsoluteFilePath; if (file == null) { return(false); } return(_fileSystem.Exists(file) && _fileSystem.Exists(project) && (SketchImportUtils.IsSketchFile(file) || file.Name.HasExtension(SketchImportUtils.SketchFilesExtension))); }