mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-17 14:30:34 +08:00
fix(build): Fix unevaluated being passed to _ref transformer.
This commit is contained in:
parent
28c862abc0
commit
537a776512
@ -671,6 +671,49 @@ const:
|
||||
text: 'Hello',
|
||||
});
|
||||
});
|
||||
|
||||
test('buildRefs pass vars two levels with a transformer', async () => {
|
||||
const files = [
|
||||
{
|
||||
path: 'lowdefy.yaml',
|
||||
content: `
|
||||
ref1:
|
||||
_ref:
|
||||
path: file1.yaml
|
||||
vars:
|
||||
var1: Hello`,
|
||||
},
|
||||
{
|
||||
path: 'file1.yaml',
|
||||
content: `
|
||||
ref2:
|
||||
_ref:
|
||||
path: file2.yaml
|
||||
transformer: src/test/buildRefs/testBuildRefsTransformIdentity.js
|
||||
vars:
|
||||
var2:
|
||||
_var: var1`,
|
||||
},
|
||||
{
|
||||
path: 'file2.yaml',
|
||||
content: `a: 1`,
|
||||
},
|
||||
];
|
||||
mockReadConfigFile.mockImplementation(readConfigFileMockImplementation(files));
|
||||
const res = await buildRefs({ context });
|
||||
expect(res).toEqual({
|
||||
ref1: {
|
||||
ref2: {
|
||||
obj: {
|
||||
a: 1,
|
||||
},
|
||||
vars: {
|
||||
var2: 'Hello',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformer functions', () => {
|
||||
|
@ -53,7 +53,7 @@ async function recursiveParseFile({ context, refDef, count, referencedFrom }) {
|
||||
const transformedFile = await runTransformer({
|
||||
context,
|
||||
parsedFile,
|
||||
refDef: newRefDef,
|
||||
refDef: parsedRefDef,
|
||||
});
|
||||
|
||||
parsedFiles[newRefDef.id] = transformedFile;
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
function transformer(obj, vars) {
|
||||
return {
|
||||
obj,
|
||||
vars,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = transformer;
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
const transformer = (_, obj) => {
|
||||
console.log('transformer', _, obj);
|
||||
const examples = {
|
||||
id: 'examples',
|
||||
type: 'Box',
|
||||
@ -29,7 +30,7 @@ const transformer = (_, obj) => {
|
||||
type: 'Markdown',
|
||||
properties: {
|
||||
content: `##### ${example.title}
|
||||
|
||||
|
||||
${example.description || ''}
|
||||
`,
|
||||
},
|
||||
@ -55,7 +56,7 @@ ${example.description || ''}
|
||||
properties: {
|
||||
content: {
|
||||
_nunjucks: {
|
||||
template: `
|
||||
template: `
|
||||
\`\`\`yaml
|
||||
{{ block }}
|
||||
\`\`\`
|
||||
|
Loading…
Reference in New Issue
Block a user