Skip to content

Commit 1b01435

Browse files
committed
chore: remove initializeProjectDataSafe and use try/catch instead
1 parent 54435dc commit 1b01435

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

lib/common/commands/device/get-file.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ export class GetFileCommand implements ICommand {
1212
let appIdentifier = args[1];
1313

1414
if (!appIdentifier) {
15-
this.$projectData.initializeProjectDataSafe();
15+
try {
16+
this.$projectData.initializeProjectData();
17+
} catch (err) {
18+
// ignore the error
19+
}
1620
if (!this.$projectData.projectIdentifiers) {
1721
this.$errors.failWithoutHelp("Please enter application identifier or execute this command in project.");
1822
}

lib/common/commands/device/list-files.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export class ListFilesCommand implements ICommand {
1313
let appIdentifier = args[1];
1414

1515
if (!appIdentifier) {
16-
this.$projectData.initializeProjectDataSafe();
16+
try {
17+
this.$projectData.initializeProjectData();
18+
} catch (err) {
19+
// ignore the error
20+
}
1721
if (!this.$projectData.projectIdentifiers) {
1822
this.$errors.failWithoutHelp("Please enter application identifier or execute this command in project.");
1923
}

lib/common/commands/device/put-file.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ export class PutFileCommand implements ICommand {
1212
let appIdentifier = args[2];
1313

1414
if (!appIdentifier) {
15-
this.$projectData.initializeProjectDataSafe();
15+
try {
16+
this.$projectData.initializeProjectData();
17+
} catch (err) {
18+
// ignore the error
19+
}
1620
if (!this.$projectData.projectIdentifiers) {
1721
this.$errors.failWithoutHelp("Please enter application identifier or execute this command in project.");
1822
}

lib/definitions/project.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ interface IProjectData extends ICreateProjectData {
104104
* @returns {void}
105105
*/
106106
initializeProjectData(projectDir?: string): void;
107-
initializeProjectDataSafe(projectDir?: string): void;
108107
initializeProjectDataFromContent(packageJsonContent: string, nsconfigContent: string, projectDir?: string): void;
109108
getAppDirectoryPath(projectDir?: string): string;
110109
getAppDirectoryRelativePath(): string;

lib/project-data.ts

-8
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ export class ProjectData implements IProjectData {
9090
this.errorInvalidProject(projectDir);
9191
}
9292

93-
public initializeProjectDataSafe(projectDir?: string): void {
94-
try {
95-
return this.initializeProjectData(projectDir);
96-
} catch (err) {
97-
// ignore the error
98-
}
99-
}
100-
10193
public initializeProjectDataFromContent(packageJsonContent: string, nsconfigContent: string, projectDir?: string): void {
10294
projectDir = projectDir || this.$projectHelper.projectDir || "";
10395
const projectFilePath = this.getProjectFilePath(projectDir);

test/stubs.ts

-3
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,6 @@ export class ProjectDataStub implements IProjectData {
336336
this.projectIdentifiers = { android: "", ios: "" };
337337
this.projectId = "";
338338
}
339-
public initializeProjectDataSafe(projectDir?: string): void {
340-
this.initializeProjectData(projectDir);
341-
}
342339
public initializeProjectDataFromContent(): void {
343340
return;
344341
}

0 commit comments

Comments
 (0)