mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-19 14:23:32 -04:00
@@ -83,7 +83,7 @@ rollup.rollup(configJSAPIMockInput).then(bundle => {
|
||||
bundle.write(configJSAPIMockOutput).then(() => {
|
||||
countSize(configJSAPIMockOutput.file);
|
||||
const fileContent = fs.readFileSync(configJSAPIMockOutput.file, 'utf-8');
|
||||
fs.writeFileSync(configJSAPIMockOutput.file, fileContent.replace(/\$\d*/g, ''), 'utf-8');
|
||||
fs.writeFileSync(configJSAPIMockOutput.file, fileContent.replace(/CommonMethod\$\d*/g, 'CommonMethod'), 'utf-8');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { SyntaxKind } from 'typescript';
|
||||
import type { SourceFile } from 'typescript';
|
||||
import { firstCharacterToUppercase } from '../common/commonUtils';
|
||||
@@ -43,7 +44,10 @@ import { generateVariableStatementDelcatation } from './generateVariableStatemen
|
||||
export function generateModuleDeclaration(rootName: string, moduleEntity: ModuleBlockEntity, sourceFile: SourceFile, filename: string): string {
|
||||
let moduleName = moduleEntity.moduleName.replace(/["']/g, '');
|
||||
let moduleBody = `export function mock${firstCharacterToUppercase(moduleName)}() {\n`;
|
||||
if (!moduleEntity.exportModifiers.includes(SyntaxKind.DeclareKeyword) && moduleEntity.moduleName.startsWith('"')) {
|
||||
if (!(moduleEntity.exportModifiers.includes(SyntaxKind.DeclareKeyword) &&
|
||||
(moduleEntity.moduleName.startsWith('"') || moduleEntity.moduleName.startsWith('\''))) &&
|
||||
path.basename(sourceFile.fileName).startsWith('@ohos')
|
||||
) {
|
||||
addToIndexArray({ fileName: filename, mockFunctionName: `mock${firstCharacterToUppercase(moduleName)}` });
|
||||
}
|
||||
let outBody = '';
|
||||
|
||||
Reference in New Issue
Block a user