Skip to content
This repository has been archived by the owner on Nov 14, 2019. It is now read-only.

Add support for constants #153

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"is-git-url": "^1.0.0",
"js-yaml": "^3.13.1",
"lodash.pick": "^4.4.0",
"mesg-js": "^4.3.1",
"mesg-js": "github:mesg-foundation/mesg-js#build/add-mapping-constant-support",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want rather version of mesg-js here, won't we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is just temporary to test the feature and shouldn't be merged until the dependency mesg-foundation/mesg-js#132 is merged and released as beta. There is a dependency for this PR

"node-docker-api": "^1.1.22",
"rimraf": "^2.6.3",
"tar": "^4.4.8",
Expand Down
15 changes: 11 additions & 4 deletions src/utils/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import yaml from 'js-yaml'
import pick from 'lodash.pick'
import * as ProcessType from 'mesg-js/lib/api/typedef/process'
import {hash, Process, Service} from 'mesg-js/lib/api/types'
import {encodeField} from 'mesg-js/lib/util/encoder'

const replaceVariable = (value: any, env: { [key: string]: string }) => {
if (typeof value !== 'string') return value
Expand Down Expand Up @@ -79,10 +80,16 @@ const nodeCompiler = async (
key,
outputs: Object.keys(def).map(key => ({
key,
ref: {
key: def[key].key,
nodeKey: def[key].stepKey || opts.defaultNodeKey,
}
...(typeof def[key] === 'object' && def[key].key // if the value is an object containing an attribute key
? {
ref: {
key: def[key].key,
nodeKey: def[key].stepKey || opts.defaultNodeKey,
}
}
: {
constant: encodeField(def[key])
})
}))
}),
filter: async (def: any, key: string, opts: any): Promise<ProcessType.types.Process.Node.IFilter> => ({
Expand Down