cli: fix yaml transform and add test for loading yaml

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-20 18:02:28 +02:00
parent f368ad7279
commit 1720afed04
3 changed files with 28 additions and 1 deletions
+3 -1
View File
@@ -15,6 +15,7 @@
*/
const yaml = require('yaml');
const crypto = require('crypto');
function createTransformer(config) {
const process = source => {
@@ -23,7 +24,8 @@ function createTransformer(config) {
};
const getCacheKey = sourceText => {
return createHash('md5')
return crypto
.createHash('md5')
.update(sourceText)
.update(Buffer.alloc(1))
.update(JSON.stringify(config))
+2
View File
@@ -0,0 +1,2 @@
x:
y: 'z'
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright 2022 The Backstage Authors
*
* 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.
*/
import yaml from './yaml-fixture.yaml';
describe('tests', () => {
it('should load yaml', () => {
expect(yaml).toEqual({ x: { y: 'z' } });
});
});