Skip to content

Commit d4e94d5

Browse files
Make fs.copyFile sync
1 parent 8007d43 commit d4e94d5

File tree

12 files changed

+57
-53
lines changed

12 files changed

+57
-53
lines changed

lib/commands/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class BuildCommandBase {
77
let platform = args[0].toLowerCase();
88
this.$platformService.buildPlatform(platform, null, true).wait();
99
if(this.$options.copyTo) {
10-
this.$platformService.copyLastOutput(platform, this.$options.copyTo, {isForDevice: this.$options.forDevice}).wait();
10+
this.$platformService.copyLastOutput(platform, this.$options.copyTo, {isForDevice: this.$options.forDevice});
1111
}
1212
}).future<void>()();
1313
}

lib/commands/test-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TestInitCommand implements ICommand {
6060
let exampleFilePath = this.$resources.resolvePath(`test/example.${frameworkToInstall}.js`);
6161

6262
if (shouldCreateSampleTests && this.$fs.exists(exampleFilePath)) {
63-
this.$fs.copyFile(exampleFilePath, path.join(testsDir, 'example.js')).wait();
63+
this.$fs.copyFile(exampleFilePath, path.join(testsDir, 'example.js'));
6464
this.$logger.info('\nExample test file created in app/tests/'.yellow);
6565
} else {
6666
this.$logger.info('\nPlace your test files under app/tests/'.yellow);

lib/definitions/platform.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ interface IPlatformService {
5050
*/
5151
getLatestApplicationPackageForEmulator(platformData: IPlatformData): IApplicationPackage;
5252

53-
copyLastOutput(platform: string, targetPath: string, settings: {isForDevice: boolean}): IFuture<void>;
53+
/**
54+
* Copies latest build output to a specified location.
55+
* @param {string} platform Mobile platform - Android, iOS.
56+
* @param {string} targetPath Destination where the build artifact should be copied.
57+
* @param {{isForDevice: boolean}} settings Defines if the searched artifact should be for simulator.
58+
* @returns {void}
59+
*/
60+
copyLastOutput(platform: string, targetPath: string, settings: {isForDevice: boolean}): void;
61+
5462
lastOutputPath(platform: string, settings: { isForDevice: boolean }): string;
5563
ensurePlatformInstalled(platform: string): IFuture<void>;
5664
}

lib/definitions/project.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ interface IPlatformProjectService {
152152

153153
deploy(deviceIdentifier: string): IFuture<void>;
154154
processConfigurationFilesFromAppResources(): IFuture<void>;
155+
155156
/**
156157
* Ensures there is configuration file (AndroidManifest.xml, Info.plist) in app/App_Resources.
158+
* @returns {void}
157159
*/
158-
ensureConfigurationFileInAppResources(): IFuture<void>;
160+
ensureConfigurationFileInAppResources(): void;
159161
}
160162

161163
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
302302

303303
public prepareProject(): void {
304304
// Intentionally left empty.
305-
}
305+
}
306306

307-
public ensureConfigurationFileInAppResources(): IFuture<void> {
308-
return (() => {
309-
let originalAndroidManifestFilePath = path.join(this.$projectData.appResourcesDirectoryPath, this.$devicePlatformsConstants.Android, this.platformData.configurationFileName);
307+
public ensureConfigurationFileInAppResources(): void {
308+
let originalAndroidManifestFilePath = path.join(this.$projectData.appResourcesDirectoryPath, this.$devicePlatformsConstants.Android, this.platformData.configurationFileName);
310309

311-
let manifestExists = this.$fs.exists(originalAndroidManifestFilePath);
312-
if (!manifestExists) {
313-
this.$logger.warn('No manifest found in ' + originalAndroidManifestFilePath);
314-
return;
315-
}
316-
// Overwrite the AndroidManifest from runtime.
317-
this.$fs.copyFile(originalAndroidManifestFilePath, this.platformData.configurationFilePath).wait();
318-
}).future<void>()();
310+
let manifestExists = this.$fs.exists(originalAndroidManifestFilePath);
311+
if (!manifestExists) {
312+
this.$logger.warn('No manifest found in ' + originalAndroidManifestFilePath);
313+
return;
314+
}
315+
// Overwrite the AndroidManifest from runtime.
316+
this.$fs.copyFile(originalAndroidManifestFilePath, this.platformData.configurationFilePath);
319317
}
320318

321319
public prepareAppResources(appResourcesDirectoryPath: string): void {

lib/services/app-files-updater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class AppFilesUpdater {
8787
return this.fs.createDirectory(destinationPath);
8888
}
8989

90-
return this.fs.copyFile(source, destinationPath).wait();
90+
return this.fs.copyFile(source, destinationPath);
9191
});
9292
}
9393
}

lib/services/ios-project-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
558558
this.platformData.configurationFileName
559559
);
560560
}
561-
public ensureConfigurationFileInAppResources(): IFuture<void> {
562-
return Future.fromResult();
561+
public ensureConfigurationFileInAppResources(): void {
562+
return null;
563563
}
564564

565565
private mergeInfoPlists(): IFuture<void> {
566566
return (() => {
567567
let projectDir = this.$projectData.projectDir;
568568
let infoPlistPath = this.$options.baseConfig || path.join(projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME, this.platformData.normalizedPlatformName, this.platformData.configurationFileName);
569-
this.ensureConfigurationFileInAppResources().wait();
569+
this.ensureConfigurationFileInAppResources();
570570

571571
if (!this.$fs.exists(infoPlistPath)) {
572572
this.$logger.trace("Info.plist: No app/App_Resources/iOS/Info.plist found, falling back to pre-1.6.0 Info.plist behavior.");

lib/services/itmstransporter-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class ITMSTransporterService implements IITMSTransporterService {
4242

4343
this.$fs.createDirectory(innerDirectory);
4444

45-
this.$fs.copyFile(data.ipaFilePath, ipaFileLocation).wait();
45+
this.$fs.copyFile(data.ipaFilePath, ipaFileLocation);
4646

4747
let ipaFileHash = this.$fs.getFileShasum(ipaFileLocation, {algorithm: "md5"}).wait(),
4848
ipaFileSize = this.$fs.getFileSize(ipaFileLocation),

lib/services/platform-service.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ export class PlatformService implements IPlatformService {
122122
let customTemplateOptions = this.getPathToPlatformTemplate(this.$options.platformTemplate, platformData.frameworkPackageName).wait();
123123
let pathToTemplate = customTemplateOptions && customTemplateOptions.pathToTemplate;
124124
platformData.platformProjectService.createProject(path.resolve(frameworkDir), installedVersion, pathToTemplate).wait();
125-
platformData.platformProjectService.ensureConfigurationFileInAppResources().wait();
125+
platformData.platformProjectService.ensureConfigurationFileInAppResources();
126126
platformData.platformProjectService.interpolateData().wait();
127127
platformData.platformProjectService.afterCreateProject(platformData.projectRoot);
128128

129-
this.applyBaseConfigOption(platformData).wait();
129+
this.applyBaseConfigOption(platformData);
130130

131131
let frameworkPackageNameData: any = { version: installedVersion };
132132
if (customTemplateOptions) {
@@ -255,7 +255,7 @@ export class PlatformService implements IPlatformService {
255255
this.$projectFilesManager.processPlatformSpecificFiles(directoryPath, platform, excludedDirs);
256256

257257
if (changeInfo.configChanged || changeInfo.modulesChanged) {
258-
this.applyBaseConfigOption(platformData).wait();
258+
this.applyBaseConfigOption(platformData);
259259
platformData.platformProjectService.processConfigurationFilesFromAppResources().wait();
260260
}
261261

@@ -268,7 +268,7 @@ export class PlatformService implements IPlatformService {
268268
private copyAppFiles(platform: string): IFuture<void> {
269269
return (() => {
270270
let platformData = this.$platformsData.getPlatformData(platform);
271-
platformData.platformProjectService.ensureConfigurationFileInAppResources().wait();
271+
platformData.platformProjectService.ensureConfigurationFileInAppResources();
272272
let appDestinationDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
273273

274274
// Copy app folder to native project
@@ -376,23 +376,21 @@ export class PlatformService implements IPlatformService {
376376
return packageFile;
377377
}
378378

379-
public copyLastOutput(platform: string, targetPath: string, settings: { isForDevice: boolean }): IFuture<void> {
380-
return (() => {
381-
platform = platform.toLowerCase();
382-
targetPath = path.resolve(targetPath);
379+
public copyLastOutput(platform: string, targetPath: string, settings: { isForDevice: boolean }): void {
380+
platform = platform.toLowerCase();
381+
targetPath = path.resolve(targetPath);
383382

384-
let packageFile = this.lastOutputPath(platform, settings);
383+
let packageFile = this.lastOutputPath(platform, settings);
385384

386-
this.$fs.ensureDirectoryExists(path.dirname(targetPath));
385+
this.$fs.ensureDirectoryExists(path.dirname(targetPath));
387386

388-
if (this.$fs.exists(targetPath) && this.$fs.getFsStats(targetPath).isDirectory()) {
389-
let sourceFileName = path.basename(packageFile);
390-
this.$logger.trace(`Specified target path: '${targetPath}' is directory. Same filename will be used: '${sourceFileName}'.`);
391-
targetPath = path.join(targetPath, sourceFileName);
392-
}
393-
this.$fs.copyFile(packageFile, targetPath).wait();
394-
this.$logger.info(`Copied file '${packageFile}' to '${targetPath}'.`);
395-
}).future<void>()();
387+
if (this.$fs.exists(targetPath) && this.$fs.getFsStats(targetPath).isDirectory()) {
388+
let sourceFileName = path.basename(packageFile);
389+
this.$logger.trace(`Specified target path: '${targetPath}' is directory. Same filename will be used: '${sourceFileName}'.`);
390+
targetPath = path.join(targetPath, sourceFileName);
391+
}
392+
this.$fs.copyFile(packageFile, targetPath);
393+
this.$logger.info(`Copied file '${packageFile}' to '${targetPath}'.`);
396394
}
397395

398396
public removePlatforms(platforms: string[]): void {
@@ -641,14 +639,12 @@ export class PlatformService implements IPlatformService {
641639
}).future<void>()();
642640
}
643641

644-
private applyBaseConfigOption(platformData: IPlatformData): IFuture<void> {
645-
return (() => {
646-
if (this.$options.baseConfig) {
647-
let newConfigFile = path.resolve(this.$options.baseConfig);
648-
this.$logger.trace(`Replacing '${platformData.configurationFilePath}' with '${newConfigFile}'.`);
649-
this.$fs.copyFile(newConfigFile, platformData.configurationFilePath).wait();
650-
}
651-
}).future<void>()();
642+
private applyBaseConfigOption(platformData: IPlatformData): void {
643+
if (this.$options.baseConfig) {
644+
let newConfigFile = path.resolve(this.$options.baseConfig);
645+
this.$logger.trace(`Replacing '${platformData.configurationFilePath}' with '${newConfigFile}'.`);
646+
this.$fs.copyFile(newConfigFile, platformData.configurationFilePath);
647+
}
652648
}
653649
}
654650
$injector.register("platformService", PlatformService);

test/npm-support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function setupProject(dependencies?: any): IFuture<any> {
149149
beforePrepareAllPlugins: () => Future.fromResult(),
150150
getAppResourcesDestinationDirectoryPath: () => path.join(androidFolderPath, "src", "main", "res"),
151151
processConfigurationFilesFromAppResources: () => Future.fromResult(),
152-
ensureConfigurationFileInAppResources: () => Future.fromResult(),
152+
ensureConfigurationFileInAppResources: (): any => null,
153153
interpolateConfigurationFile: () => Future.fromResult(),
154154
isPlatformPrepared: (projectRoot: string) => false
155155
}

0 commit comments

Comments
 (0)