« get me outta code hell

inheritFromMainRelease.js « track « things « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/track/inheritFromMainRelease.js
blob: b1cbb65e8ae182d4284773c964dec5846ffab6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Early exits with the value for the same property as specified on the
// main release, if this track is a secondary release, and otherwise continues
// without providing any further dependencies.
//
// Like withMainRelease, this will early exit (with notFoundValue) if the
// main release is specified by reference and that reference doesn't
// resolve to anything.

import {input, templateCompositeFrom} from '#composite';

import {exposeDependency, raiseOutputWithoutDependency}
  from '#composite/control-flow';

import withPropertyFromMainRelease
  from './withPropertyFromMainRelease.js';

export default templateCompositeFrom({
  annotation: `inheritFromMainRelease`,

  inputs: {
    notFoundValue: input({
      defaultValue: null,
    }),
  },

  steps: () => [
    withPropertyFromMainRelease({
      property: input.thisProperty(),
      notFoundValue: input('notFoundValue'),
    }),

    raiseOutputWithoutDependency({
      dependency: '#isSecondaryRelease',
      mode: input.value('falsy'),
    }),

    exposeDependency({
      dependency: '#mainReleaseValue',
    }),
  ],
});