From 44f4744ee260bdc7aa5eec1e5c35f736a00dd41e Mon Sep 17 00:00:00 2001
From: qiang <guoshengqiang@live.com>
Date: Fri, 12 Mar 2021 20:47:42 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=AE=89=E8=A3=85?=
 =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=20npm=20=E4=BE=9D?=
 =?UTF-8?q?=E8=B5=96=20close=20#24?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 generator.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/generator.js b/generator.js
index 03f000d..fe4ee6a 100644
--- a/generator.js
+++ b/generator.js
@@ -115,6 +115,23 @@ module.exports = (api, options, rootOptions) => {
         })
       })
 
+      // 合并模板依赖
+      const jsonPath = path.join(tmp, './package.json')
+      if (fs.existsSync(jsonPath)) {
+        try {
+          const json = fs.readFileSync(jsonPath, { encoding: 'utf-8' })
+          content = JSON.parse(json)
+          api.extendPackage(pkg => {
+            return {
+              dependencies: Object.assign({}, content.dependencies),
+              devDependencies: Object.assign({}, content.devDependencies)
+            }
+          })
+        } catch (error) {
+          console.warn('package.json merge failed')
+        }
+      }
+
       const dirNames = ['cloudfunctions-aliyun', 'cloudfunctions-tcb']
       dirNames.forEach(dirName => {
         const dirPath = path.join(tmp, './', dirName)