Skip to content

Commit 19a0115

Browse files
authored
fix: yaml extend (#102)
* fix: yaml extends bug Signed-off-by: xsahxl <xsahxl@126.com>
1 parent cbf7804 commit 19a0115

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/core",
3-
"version": "0.1.54",
3+
"version": "0.1.55",
44
"description": "Serverless Devs Tool Core Component",
55
"keywords": [
66
"Serverless",

publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Type: Component
22
Name: core
33
Provider:
44
- 阿里云
5-
Version: 0.1.54
5+
Version: 0.1.55
66
Description: Serverless Devs 核心组件
77
HomePage: https://github.com/Serverless-Devs/core
88
Tags: #标签详情

src/common/execCommand/getTemplatePath.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,15 @@ async function extendsYaml(spath: string, dotspath: string) {
8181
}
8282

8383
await isYamlFile(baseYamlPath);
84+
// 解析base yaml之前,先合并vars
85+
if (data?.vars) {
86+
const baseYamlData = await getYamlContent(baseYamlPath);
87+
const newData = extend2(true, {}, baseYamlData, { vars: data.vars });
88+
// 临时写到dotspath
89+
fs.writeFileSync(dotspath, yaml.dump(newData));
90+
}
8491
// 解析base yaml
85-
const baseYamlData = await parseYaml(fs.readFileSync(baseYamlPath, 'utf-8'));
92+
const baseYamlData = await parseYaml(fs.readFileSync(dotspath, 'utf-8'));
8693
// 只合并vars
8794
const newData = extend2(true, {}, { vars: baseYamlData?.vars }, data);
8895
fs.writeFileSync(dotspath, yaml.dump(newData));

src/daemon/constant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
DEFAULT_CORE_VERSION: '0.1.54',
2+
DEFAULT_CORE_VERSION: '0.1.55',
33
};

0 commit comments

Comments
 (0)