Skip to content

Commit 3b68ab2

Browse files
committed
Fix PR comments
1 parent 897cf32 commit 3b68ab2

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lib/services/files-hash-service.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ import { executeActionByChunks } from "../common/helpers";
22
import { DEFAULT_CHUNK_SIZE } from "../common/constants";
33

44
export class FilesHashService implements IFilesHashService {
5-
constructor(private $fs: IFileSystem) { }
5+
constructor(private $fs: IFileSystem,
6+
private $logger: ILogger) { }
67

78
public async generateHashes(files: string[]): Promise<IStringDictionary> {
89
const result: IStringDictionary = {};
910

1011
const action = async (file: string) => {
11-
if (this.$fs.getFsStats(file).isFile()) {
12-
result[file] = await this.$fs.getFileShasum(file);
12+
try {
13+
const isFile = this.$fs.getFsStats(file).isFile();
14+
if (isFile) {
15+
result[file] = await this.$fs.getFileShasum(file);
16+
}
17+
} catch (err) {
18+
this.$logger.trace(`Unable to generate hash for file ${file}. Error is: ${err}`);
1319
}
1420
};
1521

lib/services/project-changes-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from "path";
2-
import { NODE_MODULES_FOLDER_NAME, NativePlatformStatus, PACKAGE_JSON_FILE_NAME, APP_GRADLE_FILE_NAME, BUILD_XCCONFIG_FILE_NAME, APP_RESOURCES_FOLDER_NAME } from "../constants";
2+
import { NODE_MODULES_FOLDER_NAME, NativePlatformStatus, PACKAGE_JSON_FILE_NAME, APP_GRADLE_FILE_NAME, BUILD_XCCONFIG_FILE_NAME } from "../constants";
33
import { getHash } from "../common/helpers";
44

55
const prepareInfoFileName = ".nsprepareinfo";
@@ -59,8 +59,8 @@ export class ProjectChangesService implements IProjectChangesService {
5959
public async checkForChanges(platform: string, projectData: IProjectData, projectChangesOptions: IProjectChangesOptions): Promise<IProjectChangesInfo> {
6060
const platformData = this.$platformsData.getPlatformData(platform, projectData);
6161
this._changesInfo = new ProjectChangesInfo();
62-
const isPrepareInfoEnsured = await this.ensurePrepareInfo(platform, projectData, projectChangesOptions);
63-
if (!isPrepareInfoEnsured) {
62+
const isNewPrepareInfo = await this.ensurePrepareInfo(platform, projectData, projectChangesOptions);
63+
if (!isNewPrepareInfo) {
6464
this._newFiles = 0;
6565

6666
this._changesInfo.appFilesChanged = await this.hasChangedAppFiles(projectData);
@@ -178,7 +178,7 @@ export class ProjectChangesService implements IProjectChangesService {
178178
changesRequireBuild: true,
179179
projectFileHash: this.getProjectFileStrippedHash(projectData, platform),
180180
changesRequireBuildTime: null,
181-
appFilesHashes: await this.$filesHashService.generateHashes(this.getAppFiles(projectData.appDirectoryPath))
181+
appFilesHashes: await this.$filesHashService.generateHashes(this.getAppFiles(projectData))
182182
};
183183

184184
this._outputProjectMtime = 0;
@@ -306,12 +306,12 @@ export class ProjectChangesService implements IProjectChangesService {
306306
return false;
307307
}
308308

309-
private getAppFiles(appDirectoryPath: string): string[] {
310-
return this.$fs.enumerateFilesInDirectorySync(appDirectoryPath, (filePath: string, stat: IFsStats) => filePath.indexOf(APP_RESOURCES_FOLDER_NAME) === -1);
309+
private getAppFiles(projectData: IProjectData): string[] {
310+
return this.$fs.enumerateFilesInDirectorySync(projectData.appDirectoryPath, (filePath: string, stat: IFsStats) => filePath !== projectData.appResourcesDirectoryPath);
311311
}
312312

313313
private async hasChangedAppFiles(projectData: IProjectData): Promise<boolean> {
314-
const files = this.getAppFiles(projectData.appDirectoryPath);
314+
const files = this.getAppFiles(projectData);
315315
const changedFiles = await this.$filesHashService.getChanges(files, this._prepareInfo.appFilesHashes || {});
316316
const hasChanges = changedFiles && _.keys(changedFiles).length > 0;
317317
if (hasChanges) {

0 commit comments

Comments
 (0)