Merge pull request !165 from 卡哥/cherry-pick-1646744817
This commit is contained in:
openharmony_ci
2022-03-10 12:16:36 +00:00
committed by Gitee
2 changed files with 1855 additions and 3033 deletions
+1829 -3033
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -122,6 +122,7 @@ class ResourcePlugin {
}
addPageEntryObj();
entryObj = Object.assign(entryObj, abilityEntryObj);
checkTestRunner(input, entryObj);
for (const key in entryObj) {
if (!compiler.options.entry[key]) {
const singleEntry = new SingleEntryPlugin('', entryObj[key], key);
@@ -373,4 +374,29 @@ function setCSSEntry(cssfiles, key) {
}
}
function checkTestRunner(projectPath, entryObj) {
const testRunnerPath = path.join(path.parse(projectPath).dir, 'TestRunner');
if ((!fs.existsSync(testRunnerPath)) || !fs.statSync(testRunnerPath).isDirectory()) {
return;
}
const files = [];
walkSync(testRunnerPath, files, entryObj, projectPath);
}
function walkSync(filePath_, files, entryObj, projectPath) {
fs.readdirSync(filePath_).forEach(function (name) {
const filePath = path.join(filePath_, name);
const stat = fs.statSync(filePath);
if (stat.isFile()) {
const extName = '.js';
if (path.extname(filePath) === extName) {
const key = filePath.replace(path.parse(projectPath).dir, '').replace(extName, '');
entryObj[`../${key}`] = filePath;
} else if (stat.isDirectory()) {
walkSync(filePath, files, entryObj, projectPath);
}
}
})
}
module.exports = ResourcePlugin;