diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 64ab86c9127537aecf86103a4672ab1b891be617..3fcdaf94067a6161d93439937eace55e836a35fc 100755 --- a/build-tools/handleApiFiles.js +++ b/build-tools/handleApiFiles.js @@ -29,6 +29,15 @@ const DirType = { 'typeThree': 'noTagInEts2', }; +const NotNullFilePath = [ + 'api', + 'api/@internal/ets', + 'api/@internal/component/ets', + 'api/arkui/component', + 'arkts', + 'kits', +]; + const NOT_COPY_DIR = ['build-tools', '.git', '.gitee']; function isEtsFile(path) { @@ -102,6 +111,20 @@ function handleApiFiles(rootPath, type, output) { console.log('error===>', error); } } + if (type === DirType.typeTwo) { + NotNullFilePath.forEach((dir) => { + const outDir = path.join(output, dir); + if (!fs.existsSync(outDir)) { + fs.mkdirSync(outDir, { recursive: true }); + writeFile(path.join(outDir, '.keep'), ' '); + return; + } + const fileNames = fs.readdirSync(outDir); + if (fileNames.length === 0) { + writeFile(path.join(outDir, '.keep'), ' '); + } + }); + } }