diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 2cad66e2f00b5ba1d7f8127c420f42fdf6aa8326..677a681c82f0c00425ef93151e6a37d717bd2d2d 100755 --- a/build-tools/handleApiFiles.js +++ b/build-tools/handleApiFiles.js @@ -30,6 +30,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) { @@ -103,6 +112,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'), ' '); + } + }); + } }