Comparing version 1.0.2 to 1.0.3
@@ -35,3 +35,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ // eslint-disable-next-line no-unused-vars | ||
/******/ var hotCurrentHash = "6e6d96300003b090de8f"; | ||
/******/ var hotCurrentHash = "fc045e83128bac09b2ba"; | ||
/******/ var hotRequestTimeout = 10000; | ||
@@ -1214,17 +1214,25 @@ /******/ var hotCurrentModuleData = {}; | ||
if (root === void 0) { root = {}; } | ||
var keys = Object.keys(content); | ||
keys.forEach(function (key) { | ||
var value = content[key]; | ||
var node = null; | ||
if (typeof value === "string") { | ||
node = print(parseToken(value), basePath, key); | ||
} | ||
else if (typeof value === "object") { | ||
var child = {}; | ||
value = print(parse(value, child, basePath), basePath, key); | ||
} | ||
var newValue = node || value; | ||
root[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
if (typeof content === "object") { | ||
var keys = Object.keys(content); | ||
keys.forEach(function (key) { | ||
var value = content[key]; | ||
var node = null; | ||
if (typeof value === "string") { | ||
node = print(parseToken(value), basePath, key); | ||
} | ||
else if (typeof value === "object") { | ||
var child = {}; | ||
value = print(parse(value, child, basePath), basePath, key); | ||
} | ||
var newValue = node || value; | ||
root[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
} | ||
else if (typeof content === "string") { | ||
return print(parseToken(content), basePath, ""); | ||
} | ||
else { | ||
return content; | ||
} | ||
return root; | ||
@@ -1231,0 +1239,0 @@ } |
{ | ||
"name": "sls-yaml", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Serverless framework yaml extension parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -250,17 +250,23 @@ const fs = require("fs"); | ||
function parse(content: any, root: any = {}, basePath: string) { | ||
const keys = Object.keys(content); | ||
keys.forEach(key => { | ||
let value = content[key]; | ||
let node = null; | ||
if (typeof value === "string") { | ||
node = print(parseToken(value), basePath, key); | ||
} else if (typeof value === "object") { | ||
const child = {}; | ||
value = print(parse(value, child, basePath), basePath, key); | ||
} | ||
const newValue = node || value; | ||
root[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
function parse(content: any, root: any = {}, basePath: string): any { | ||
if (typeof content === "object") { | ||
const keys = Object.keys(content); | ||
keys.forEach(key => { | ||
let value = content[key]; | ||
let node = null; | ||
if (typeof value === "string") { | ||
node = print(parseToken(value), basePath, key); | ||
} else if (typeof value === "object") { | ||
const child = {}; | ||
value = print(parse(value, child, basePath), basePath, key); | ||
} | ||
const newValue = node || value; | ||
root[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
} else if (typeof content === "string") { | ||
return print(parseToken(content), basePath, ""); | ||
} else { | ||
return content; | ||
} | ||
return root; | ||
@@ -267,0 +273,0 @@ } |
@@ -19,2 +19,9 @@ import yaml from "./sls-yaml"; | ||
}); | ||
describe("When passing a file reference without key", () => { | ||
it("Should replace value with file content", () => { | ||
const content = Buffer.from("${file(src/__mocks__/file.yml)}"); | ||
const doc = yaml(content); | ||
expect(doc).toEqual({ key: "value" }); | ||
}); | ||
}); | ||
describe("When passing a env reference", () => { | ||
@@ -21,0 +28,0 @@ it("Should replace env var with it's value", () => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117313
1872