Skip to content

Commit

Permalink
Fix bug again
Browse files Browse the repository at this point in the history
  • Loading branch information
prozanne committed Jun 17, 2020
1 parent 5fd1b7e commit 767f900
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions lib/hostAppHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ const RESOURCES = '.resource';

module.exports = {
setHostAppEnv: async (userAnswer, deviceInfo) => {
const hostAppConfig = await getHostAppConfig(userAnswer.baseAppPath);
await makeHostAppConfigFile(hostAppConfig);
await setBaseJSData(userAnswer, deviceInfo, hostAppConfig);
await makeHostAppConfigFile(userAnswer.baseAppPath);
await setBaseJSData(userAnswer, deviceInfo);
setBaseHtmlData(userAnswer);
},
getHostAppId: baseAppPath => {
Expand Down Expand Up @@ -192,7 +191,7 @@ function preparePackage() {
}
}

async function getHostAppConfig(baseAppPath) {
async function makeHostAppConfigFile(baseAppPath) {
let userConfigData = '';
try {
userConfigData = fs.readFileSync(
Expand All @@ -213,10 +212,6 @@ async function getHostAppConfig(baseAppPath) {
})
);

return parsedXmlData;
}

async function makeHostAppConfigFile(parsedXmlData) {
if (parsedXmlData && parsedXmlData.widget) {
setDefaultConfigData(parsedXmlData.widget);
} else {
Expand Down Expand Up @@ -311,7 +306,7 @@ function setDefaultConfigData(configData) {
}
}

async function setBaseJSData(userAnswer, deviceInfo, hostAppConfig) {
async function setBaseJSData(userAnswer, deviceInfo) {
try {
const file = path.join(
util.WITS_BASE_PATH,
Expand All @@ -321,7 +316,7 @@ async function setBaseJSData(userAnswer, deviceInfo, hostAppConfig) {
'base.js'
);
const data = fs.readFileSync(file, 'utf8');
const contentSrc = getContentSrc(userAnswer.baseAppPath, hostAppConfig);
const contentSrc = getContentSrc(userAnswer.baseAppPath);
const hostAppId = module.exports.getHostAppId(userAnswer.baseAppPath);
const hostAppName = hostAppId.split('.')[1];
const hostAppPath = deviceInfo.appInstallPath + hostAppName;
Expand Down Expand Up @@ -383,15 +378,12 @@ function setBaseHtmlData(userAnswer) {
}
}

function getContentSrc(baseAppPath, hostAppConfig) {
function getContentSrc(baseAppPath) {
let contentSrc = 'index.html';
if (hostAppConfig) {
contentSrc = hostAppConfig.widget.content[0].attributes.src;
}

try {
const file = path.resolve(path.join(baseAppPath, 'config.xml'));
const data = fs.readFileSync(file, 'utf8');
let data = fs.readFileSync(file, 'utf8');
data = util.clearComment(data);
contentSrc = data
.match(regExp.CONTENT_SRC)[0]
Expand Down

0 comments on commit 767f900

Please sign in to comment.