Skip to content

Commit 2f519e6

Browse files
Use sync version of fs.rename
1 parent 7cfb218 commit 2f519e6

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

lib/definitions/project.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ interface IPlatformProjectService {
7070
createProject(frameworkDir: string, frameworkVersion: string, pathToTemplate?: string): IFuture<void>;
7171
interpolateData(): IFuture<void>;
7272
interpolateConfigurationFile(configurationFilePath?: string): IFuture<void>;
73-
afterCreateProject(projectRoot: string): IFuture<void>;
73+
74+
/**
75+
* Executes additional actions after native project is created.
76+
* @param {string} projectRoot Path to the real NativeScript project.
77+
* @returns {void}
78+
*/
79+
afterCreateProject(projectRoot: string): void;
80+
7481
buildProject(projectRoot: string, buildConfig?: IBuildConfig): IFuture<void>;
7582
prepareProject(): IFuture<void>;
7683
prepareAppResources(appResourcesDirectoryPath: string): IFuture<void>;

lib/services/android-project-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
221221
return id;
222222
}
223223

224-
public afterCreateProject(projectRoot: string): IFuture<void> {
225-
return Future.fromResult();
224+
public afterCreateProject(projectRoot: string): void {
225+
return null;
226226
}
227227

228228
public canUpdatePlatform(newInstalledModuleDir: string): IFuture<boolean> {

lib/services/ios-project-service.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
130130
// Starting with NativeScript for iOS 1.6.0, the project Info.plist file resides not in the platform project,
131131
// but in the hello-world app template as a platform specific resource.
132132
if (this.$fs.exists(path.join(projectRootFilePath, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + "-Info.plist"))) {
133-
this.replaceFileName("-Info.plist", projectRootFilePath).wait();
133+
this.replaceFileName("-Info.plist", projectRootFilePath);
134134
}
135-
this.replaceFileName("-Prefix.pch", projectRootFilePath).wait();
135+
this.replaceFileName("-Prefix.pch", projectRootFilePath);
136136

137137
let xcschemeDirPath = path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + IOSProjectService.XCODE_PROJECT_EXT_NAME, "xcshareddata/xcschemes");
138138
let xcschemeFilePath = path.join(xcschemeDirPath, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + IOSProjectService.XCODE_SCHEME_EXT_NAME);
@@ -142,13 +142,13 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
142142
this.$logger.debug("Checkpoint 0");
143143
this.replaceFileContent(xcschemeFilePath).wait();
144144
this.$logger.debug("Checkpoint 1");
145-
this.replaceFileName(IOSProjectService.XCODE_SCHEME_EXT_NAME, xcschemeDirPath).wait();
145+
this.replaceFileName(IOSProjectService.XCODE_SCHEME_EXT_NAME, xcschemeDirPath);
146146
this.$logger.debug("Checkpoint 2");
147147
} else {
148148
this.$logger.debug("Copying xcscheme from template not found at " + xcschemeFilePath);
149149
}
150150

151-
this.replaceFileName(IOSProjectService.XCODE_PROJECT_EXT_NAME, this.platformData.projectRoot).wait();
151+
this.replaceFileName(IOSProjectService.XCODE_PROJECT_EXT_NAME, this.platformData.projectRoot);
152152

153153
let pbxprojFilePath = this.pbxProjPath;
154154
this.replaceFileContent(pbxprojFilePath).wait();
@@ -162,11 +162,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
162162
}).future<void>()();
163163
}
164164

165-
public afterCreateProject(projectRoot: string): IFuture<void> {
166-
return (() => {
167-
this.$fs.rename(path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER),
168-
path.join(projectRoot, this.$projectData.projectName)).wait();
169-
}).future<void>()();
165+
public afterCreateProject(projectRoot: string): void {
166+
this.$fs.rename(path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER),
167+
path.join(projectRoot, this.$projectData.projectName));
170168
}
171169

172170
/**
@@ -779,13 +777,11 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
779777
}).future<void>()();
780778
}
781779

782-
private replaceFileName(fileNamePart: string, fileRootLocation: string): IFuture<void> {
783-
return (() => {
784-
let oldFileName = IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + fileNamePart;
785-
let newFileName = this.$projectData.projectName + fileNamePart;
780+
private replaceFileName(fileNamePart: string, fileRootLocation: string): void {
781+
let oldFileName = IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + fileNamePart;
782+
let newFileName = this.$projectData.projectName + fileNamePart;
786783

787-
this.$fs.rename(path.join(fileRootLocation, oldFileName), path.join(fileRootLocation, newFileName)).wait();
788-
}).future<void>()();
784+
this.$fs.rename(path.join(fileRootLocation, oldFileName), path.join(fileRootLocation, newFileName));
789785
}
790786

791787
private executePodInstall(): IFuture<any> {

lib/services/platform-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class PlatformService implements IPlatformService {
124124
platformData.platformProjectService.createProject(path.resolve(frameworkDir), installedVersion, pathToTemplate).wait();
125125
platformData.platformProjectService.ensureConfigurationFileInAppResources().wait();
126126
platformData.platformProjectService.interpolateData().wait();
127-
platformData.platformProjectService.afterCreateProject(platformData.projectRoot).wait();
127+
platformData.platformProjectService.afterCreateProject(platformData.projectRoot);
128128

129129
this.applyBaseConfigOption(platformData).wait();
130130

test/platform-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ describe('Platform Service Tests', () => {
255255
validate: () => Future.fromResult(),
256256
createProject: (projectRoot: string, frameworkDir: string) => Future.fromResult(),
257257
interpolateData: (projectRoot: string) => Future.fromResult(),
258-
afterCreateProject: (projectRoot: string) => Future.fromResult(),
258+
afterCreateProject: (projectRoot: string): any => null,
259259
getAppResourcesDestinationDirectoryPath: () => Future.fromResult(""),
260260
processConfigurationFilesFromAppResources: () => Future.fromResult(),
261261
ensureConfigurationFileInAppResources: () => Future.fromResult(),
@@ -329,7 +329,7 @@ describe('Platform Service Tests', () => {
329329
validate: () => Future.fromResult(),
330330
createProject: (projectRoot: string, frameworkDir: string) => Future.fromResult(),
331331
interpolateData: (projectRoot: string) => Future.fromResult(),
332-
afterCreateProject: (projectRoot: string) => Future.fromResult(),
332+
afterCreateProject: (projectRoot: string): any => null,
333333
getAppResourcesDestinationDirectoryPath: () => Future.fromResult(""),
334334
processConfigurationFilesFromAppResources: () => Future.fromResult(),
335335
ensureConfigurationFileInAppResources: () => Future.fromResult(),

test/stubs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class FileSystemStub implements IFileSystem {
134134
return undefined;
135135
}
136136

137-
rename(oldPath: string, newPath: string): IFuture<void> {
137+
rename(oldPath: string, newPath: string): void {
138138
return undefined;
139139
}
140140

@@ -170,7 +170,7 @@ export class FileSystemStub implements IFileSystem {
170170
return undefined;
171171
}
172172

173-
renameIfExists(oldPath: string, newPath: string): IFuture<boolean> {
173+
renameIfExists(oldPath: string, newPath: string): boolean {
174174
return undefined;
175175
}
176176

@@ -305,8 +305,8 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
305305
interpolateConfigurationFile(): IFuture<void> {
306306
return Future.fromResult();
307307
}
308-
afterCreateProject(projectRoot: string): IFuture<void> {
309-
return Future.fromResult();
308+
afterCreateProject(projectRoot: string): void {
309+
return null;
310310
}
311311
prepareProject(): IFuture<void> {
312312
return Future.fromResult();

0 commit comments

Comments
 (0)