Skip to content

Commit 1a2388e

Browse files
chore: extract logic for clean plugin dir to method
1 parent 86a7e55 commit 1a2388e

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/definitions/project-changes.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface IProjectChangesOptions extends IAppFilesUpdaterOptions, IProvision, IT
4242
}
4343

4444
interface ICheckForChangesOptions extends IPlatform, IProjectDataComposition {
45-
projectChangesOptions: IProjectChangesOptions
45+
projectChangesOptions: IProjectChangesOptions;
4646
}
4747

4848
interface IProjectChangesService {

lib/services/android-plugin-build-service.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
187187
});
188188

189189
if (shouldBuildAar) {
190-
// In case plugin was already built in the current process, we need to clean the old sources as they may break the new build.
191-
this.$fs.deleteDirectory(pluginTempDir);
192-
this.$fs.ensureDirectoryExists(pluginTempDir);
190+
this.cleanPluginDir(pluginTempDir);
193191

194192
const pluginTempMainSrcDir = path.join(pluginTempDir, "src", "main");
195193
await this.updateManifest(manifestFilePath, pluginTempMainSrcDir, shortPluginName);
@@ -203,16 +201,19 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
203201
return shouldBuildAar;
204202
}
205203

204+
private cleanPluginDir(pluginTempDir: string): void {
205+
// In case plugin was already built in the current process, we need to clean the old sources as they may break the new build.
206+
this.$fs.deleteDirectory(pluginTempDir);
207+
this.$fs.ensureDirectoryExists(pluginTempDir);
208+
}
209+
206210
private getSourceFilesHashes(pluginTempPlatformsAndroidDir: string, shortPluginName: string): Promise<IStringDictionary> {
207211
const pathToAar = path.join(pluginTempPlatformsAndroidDir, `${shortPluginName}.aar`);
208-
const pluginNativeDataFiles = this.$fs.enumerateFilesInDirectorySync(pluginTempPlatformsAndroidDir, (file: string, stat: IFsStats) => {
209-
return file !== pathToAar;
210-
});
211-
212+
const pluginNativeDataFiles = this.$fs.enumerateFilesInDirectorySync(pluginTempPlatformsAndroidDir, (file: string, stat: IFsStats) => file !== pathToAar);
212213
return this.$filesHashService.generateHashes(pluginNativeDataFiles);
213214
}
214215

215-
private async writePluginHashInfo(fileHashesInfo: IStringDictionary, pluginTempDir: string): Promise<void> {
216+
private writePluginHashInfo(fileHashesInfo: IStringDictionary, pluginTempDir: string): void {
216217
const buildDataFile = this.getPathToPluginBuildDataFile(pluginTempDir);
217218
this.$fs.writeJson(buildDataFile, fileHashesInfo);
218219
}
@@ -226,7 +227,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
226227
fileHashesInfo: IStringDictionary
227228
}): Promise<boolean> {
228229

229-
let shouldBuildAar = !!opts.manifestFilePath || opts.androidSourceDirectories.length > 0;
230+
let shouldBuildAar = !!opts.manifestFilePath || !!opts.androidSourceDirectories.length;
230231

231232
if (shouldBuildAar &&
232233
this.$fs.exists(opts.pluginTempDir) &&

0 commit comments

Comments
 (0)