« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/composite/things/track/inheritFromOriginalRelease.js9
-rw-r--r--src/data/composite/things/track/withOriginalRelease.js8
2 files changed, 13 insertions, 4 deletions
diff --git a/src/data/composite/things/track/inheritFromOriginalRelease.js b/src/data/composite/things/track/inheritFromOriginalRelease.js
index a9d57f86..27ed1387 100644
--- a/src/data/composite/things/track/inheritFromOriginalRelease.js
+++ b/src/data/composite/things/track/inheritFromOriginalRelease.js
@@ -3,6 +3,10 @@
 // dependencies provided. If allowOverride is true, then the continuation
 // will also be called if the original release exposed the requested
 // property as null.
+//
+// Like withOriginalRelease, this will early exit (with notFoundValue) if the
+// original release is specified by reference and that reference doesn't
+// resolve to anything.
 
 import {input, templateCompositeFrom} from '#composite';
 
@@ -14,10 +18,13 @@ export default templateCompositeFrom({
   inputs: {
     property: input({type: 'string'}),
     allowOverride: input({type: 'boolean', defaultValue: false}),
+    notFoundValue: input({defaultValue: null}),
   },
 
   steps: () => [
-    withOriginalRelease(),
+    withOriginalRelease({
+      notFoundValue: input('notFoundValue'),
+    }),
 
     {
       dependencies: [
diff --git a/src/data/composite/things/track/withOriginalRelease.js b/src/data/composite/things/track/withOriginalRelease.js
index 6e30a0a0..c7f49657 100644
--- a/src/data/composite/things/track/withOriginalRelease.js
+++ b/src/data/composite/things/track/withOriginalRelease.js
@@ -1,9 +1,8 @@
 // Just includes the original release of this track as a dependency.
 // If this track isn't a rerelease, then it'll provide null, unless the
 // {selfIfOriginal} option is set, in which case it'll provide this track
-// itself. Note that this will early exit if the original release is
-// specified by reference and that reference doesn't resolve to anything.
-// Outputs to '#originalRelease' by default.
+// itself. This will early exit (with notFoundValue) if the original release
+// is specified by reference and that reference doesn't resolve to anything.
 
 import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
@@ -23,6 +22,8 @@ export default templateCompositeFrom({
       validate: validateWikiData({referenceType: 'track'}),
       defaultDependency: 'trackData',
     }),
+
+    notFoundValue: input({defaultValue: null}),
   },
 
   outputs: ['#originalRelease'],
@@ -60,6 +61,7 @@ export default templateCompositeFrom({
 
     exitWithoutDependency({
       dependency: '#resolvedReference',
+      value: input('notFoundValue'),
     }),
 
     {