mirror of
https://github.com/openharmony/developtools_ace-js2bundle.git
synced 2026-07-19 18:23:34 -04:00
@@ -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;
|
||||
Reference in New Issue
Block a user