process importType

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: Id298f946ec0f2ede1a3a7397673def6b5cda61ba
This commit is contained in:
houhaoyu
2022-08-02 16:13:13 +08:00
parent e465fdf5c9
commit 054eab2d91
+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) => {