!899 process importType

Merge pull request !899 from houhaoyu/master14
This commit is contained in:
openharmony_ci
2022-08-09 07:37:44 +00:00
committed by Gitee
+8
View File
@@ -65,6 +65,8 @@ function generateTargetFile(filePath, output) {
const fileName = path.resolve(output, path.basename(item));
if (item === globalTsFile || item === featureAbilityPath) {
content = license + '\n\n' + processsFile(content, fileName, true);
} else {
content = processImportType(content);
}
fs.writeFile(fileName, content, err => {
if (err) {
@@ -75,6 +77,12 @@ function generateTargetFile(filePath, output) {
});
}
function processImportType(content) {
return content.replace(/(import\s*\(("|'))(\.\.\/api\/[^("|')]*("|')\)\.)/g, (item, item1, item2, item3) => {
return item1 + '../../' + item3;
})
}
function readFile(dir, fileDir) {
const files = fs.readdirSync(dir);
files.forEach((element) => {