mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-18 16:04:32 -04:00
process importType Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: Id298f946ec0f2ede1a3a7397673def6b5cda61ba
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user