From b73f1d68ca190f94f096ee41b9a9d48c83ce850b Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Wed, 4 Mar 2020 12:19:33 +0100
Subject: [PATCH] Add directory listing

---
 steps/directory_listing.cwl | 53 +++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 steps/directory_listing.cwl

diff --git a/steps/directory_listing.cwl b/steps/directory_listing.cwl
new file mode 100644
index 00000000..b4267867
--- /dev/null
+++ b/steps/directory_listing.cwl
@@ -0,0 +1,53 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+id: directory_listing
+baseCommand:
+  - find
+inputs:
+  - id: base_directory
+    type: Directory
+    inputBinding:
+      position: 0
+  - id: name
+    type: string
+    inputBinding:
+      position: 2
+      prefix: '-name'
+outputs:
+  - id: output
+    type: 'Directory[]'
+    outputBinding:
+      loadContents: true
+      glob: out_file
+      outputEval: |-
+        ${
+            var paths = self[0].contents.split("\n")
+
+            var directories = []
+            for(var path_idx in paths){
+                var path = paths[path_idx]
+                if(path === '') continue
+                directories.push(
+                    {"class": "Directory",
+                     "path": path
+                    }
+                )
+            }
+            return directories
+        }
+label: DirectoryListing
+arguments:
+  - position: 1
+    prefix: '-maxdepth'
+    valueFrom: '1'
+  - position: 1
+    prefix: '-type'
+    valueFrom: d
+hints:
+  - class: DockerRequirement
+    dockerPull: 'lofareosc/prefactor-ci:master'
+requirements:
+  - class: InlineJavascriptRequirement
+stdout: out_file
-- 
GitLab