@dcloudio/uni-cli-shared
Advanced tools
Comparing version 0.2.938 to 0.2.939
@@ -12,2 +12,3 @@ /** | ||
let globalUsingComponents = Object.create(null) | ||
let appJsonUsingComponents = Object.create(null) | ||
@@ -53,9 +54,3 @@ function updateJsonFile (name, jsonStr) { | ||
if (usingComponents) { // merge usingComponents | ||
if (!supportGlobalUsingComponents) { // 简单处理其他平台全局组件,直接合并到独立 json 中 | ||
jsonObj.usingComponents = Object.assign({}, | ||
globalUsingComponents, | ||
JSON.parse(oldJsonStr).usingComponents || {}) | ||
} else { | ||
jsonObj.usingComponents = JSON.parse(oldJsonStr).usingComponents || {} | ||
} | ||
jsonObj.usingComponents = JSON.parse(oldJsonStr).usingComponents || {} | ||
} | ||
@@ -67,7 +62,22 @@ const newJsonStr = JSON.stringify(jsonObj, null, 2) | ||
} else { // add | ||
if (!supportGlobalUsingComponents) { // 简单处理其他平台全局组件,直接合并到独立 json 中 | ||
if (usingComponents) { | ||
jsonObj.usingComponents = Object.assign({}, globalUsingComponents, jsonObj.usingComponents || {}) | ||
} | ||
updateJsonFile(name, jsonObj) | ||
} | ||
} | ||
function updateUsingGlobalComponents (name, usingGlobalComponents) { | ||
if (supportGlobalUsingComponents) { | ||
return | ||
} | ||
const oldJsonStr = getJsonFile(name) | ||
if (oldJsonStr) { // update | ||
const jsonObj = JSON.parse(oldJsonStr) | ||
jsonObj.usingGlobalComponents = usingGlobalComponents | ||
const newJsonStr = JSON.stringify(jsonObj, null, 2) | ||
if (newJsonStr !== oldJsonStr) { | ||
updateJsonFile(name, newJsonStr) | ||
} | ||
} else { // add | ||
const jsonObj = { | ||
usingGlobalComponents | ||
} | ||
updateJsonFile(name, jsonObj) | ||
@@ -85,6 +95,2 @@ } | ||
if (!supportGlobalUsingComponents) { // 简单处理其他平台全局组件,直接合并到独立 json 中 | ||
usingComponents = Object.assign({}, globalUsingComponents, usingComponents) | ||
} | ||
const oldJsonStr = getJsonFile(name) | ||
@@ -143,7 +149,18 @@ if (oldJsonStr) { // update | ||
function updateAppJsonUsingComponents (usingComponents) { | ||
appJsonUsingComponents = usingComponents | ||
} | ||
function getComponentSet () { | ||
return componentSet | ||
} | ||
function getGlobalUsingComponents () { | ||
// 合并 app.json ,main.js 全局组件 | ||
return Object.assign({}, appJsonUsingComponents, globalUsingComponents) | ||
} | ||
module.exports = { | ||
getComponentSet, | ||
getGlobalUsingComponents, | ||
updateAppJson, | ||
@@ -154,2 +171,4 @@ updatePageJson, | ||
updateUsingComponents, | ||
updateUsingGlobalComponents, | ||
updateAppJsonUsingComponents, | ||
updateComponentGenerics, | ||
@@ -156,0 +175,0 @@ updateGenericComponents, |
@@ -35,3 +35,3 @@ const fs = require('fs') | ||
} catch (e) { | ||
throw new Error(jsonFileName + ' 解析失败') | ||
console.error(jsonFileName + ' 解析失败') | ||
} | ||
@@ -38,0 +38,0 @@ } |
{ | ||
"name": "@dcloudio/uni-cli-shared", | ||
"version": "0.2.938", | ||
"version": "0.2.939", | ||
"description": "uni-cli-shared", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
36225
856