Skip to content

Commit 0866245

Browse files
author
scottbommarito
committed
make promises void
1 parent fd2820a commit 0866245

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

test/test.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ interface RNPlatform {
4141
/**
4242
* Installs the platform on the given project.
4343
*/
44-
installPlatform(projectDirectory: string): Q.Promise<string>;
44+
installPlatform(projectDirectory: string): Q.Promise<void>;
4545

4646
/**
4747
* Installs the binary of the given project on this platform.
4848
*/
49-
installApp(projectDirectory: string): Q.Promise<string>;
49+
installApp(projectDirectory: string): Q.Promise<void>;
5050

5151
/**
5252
* Builds the binary of the project on this platform.
5353
*/
54-
buildApp(projectDirectory: string): Q.Promise<string>;
54+
buildApp(projectDirectory: string): Q.Promise<void>;
5555
}
5656

5757
class RNAndroid extends Platform.Android implements RNPlatform {
@@ -83,7 +83,7 @@ class RNAndroid extends Platform.Android implements RNPlatform {
8383
/**
8484
* Installs the platform on the given project.
8585
*/
86-
installPlatform(projectDirectory: string): Q.Promise<string> {
86+
installPlatform(projectDirectory: string): Q.Promise<void> {
8787
var innerprojectDirectory: string = path.join(projectDirectory, TestConfig.TestAppName);
8888

8989
//// Set up gradle to build CodePush with the app
@@ -115,26 +115,26 @@ class RNAndroid extends Platform.Android implements RNPlatform {
115115
TestUtil.replaceString(mainActivity, TestUtil.SERVER_URL_PLACEHOLDER, this.getServerUrl());
116116
TestUtil.replaceString(mainActivity, TestUtil.ANDROID_KEY_PLACEHOLDER, this.getDefaultDeploymentKey());
117117

118-
return Q<string>(undefined);
118+
return Q<void>(null);
119119
}
120120

121121
/**
122122
* Installs the binary of the given project on this platform.
123123
*/
124-
installApp(projectDirectory: string): Q.Promise<string> {
124+
installApp(projectDirectory: string): Q.Promise<void> {
125125
var androidDirectory: string = path.join(projectDirectory, TestConfig.TestAppName, "android");
126-
return TestUtil.getProcessOutput("adb install -r " + this.getBinaryPath(projectDirectory), { cwd: androidDirectory });
126+
return TestUtil.getProcessOutput("adb install -r " + this.getBinaryPath(projectDirectory), { cwd: androidDirectory }).then(() => { return null; });
127127
}
128128

129129
/**
130130
* Builds the binary of the project on this platform.
131131
*/
132-
buildApp(projectDirectory: string): Q.Promise<string> {
132+
buildApp(projectDirectory: string): Q.Promise<void> {
133133
// In order to run on Android without the package manager, we must create a release APK and then sign it with the debug certificate.
134134
var androidDirectory: string = path.join(projectDirectory, TestConfig.TestAppName, "android");
135135
var apkPath = this.getBinaryPath(projectDirectory);
136136
return TestUtil.getProcessOutput("./gradlew assembleRelease --daemon", { cwd: androidDirectory })
137-
.then<string>(TestUtil.getProcessOutput.bind(undefined, "jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android " + apkPath + " androiddebugkey", { cwd: androidDirectory, noLogStdOut: true }));
137+
.then<void>(TestUtil.getProcessOutput.bind(undefined, "jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android " + apkPath + " androiddebugkey", { cwd: androidDirectory, noLogStdOut: true })).then(() => { return null; });
138138
}
139139
}
140140

@@ -167,7 +167,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
167167
/**
168168
* Installs the platform on the given project.
169169
*/
170-
installPlatform(projectDirectory: string): Q.Promise<string> {
170+
installPlatform(projectDirectory: string): Q.Promise<void> {
171171
var iOSProject: string = path.join(projectDirectory, TestConfig.TestAppName, "ios");
172172
var infoPlistPath: string = path.join(iOSProject, TestConfig.TestAppName, "Info.plist");
173173
var appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.m");
@@ -197,14 +197,14 @@ class RNIOS extends Platform.IOS implements RNPlatform {
197197
.then(TestUtil.copyFile.bind(undefined,
198198
path.join(TestConfig.templatePath, "ios", TestConfig.TestAppName, "AppDelegate.m"),
199199
appDelegatePath, true))
200-
.then<string>(TestUtil.replaceString.bind(undefined, appDelegatePath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName));
200+
.then<void>(TestUtil.replaceString.bind(undefined, appDelegatePath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName));
201201
}
202202

203203
/**
204204
* Installs the binary of the given project on this platform.
205205
*/
206-
installApp(projectDirectory: string): Q.Promise<string> {
207-
return TestUtil.getProcessOutput("xcrun simctl install booted " + this.getBinaryPath(projectDirectory));
206+
installApp(projectDirectory: string): Q.Promise<void> {
207+
return TestUtil.getProcessOutput("xcrun simctl install booted " + this.getBinaryPath(projectDirectory)).then(() => { return null; });
208208
}
209209

210210
/**
@@ -223,7 +223,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
223223
/**
224224
* Builds the binary of the project on this platform.
225225
*/
226-
buildApp(projectDirectory: string): Q.Promise<string> {
226+
buildApp(projectDirectory: string): Q.Promise<void> {
227227
var iOSProject: string = path.join(projectDirectory, TestConfig.TestAppName, "ios");
228228

229229
return this.getEmulatorManager().getTargetEmulator()
@@ -234,7 +234,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
234234
return TestUtil.getProcessOutput("xcodebuild -workspace " + path.join(iOSProject, TestConfig.TestAppName) + ".xcworkspace -scheme " + TestConfig.TestAppName +
235235
" -configuration Release -destination \"platform=iOS Simulator,id=" + hash + "\" -derivedDataPath build", { cwd: iOSProject, maxBuffer: 1024 * 1000 * 10, noLogStdOut: true });
236236
})
237-
.then<string>(
237+
.then<void>(
238238
() => { return null; },
239239
() => {
240240
// The first time an iOS project is built, it fails because it does not finish building libReact.a before it builds the test app.
@@ -268,9 +268,9 @@ class RNProjectManager extends ProjectManager {
268268
/**
269269
* Copies over the template files into the specified project, overwriting existing files.
270270
*/
271-
public copyTemplate(templatePath: string, projectDirectory: string): Q.Promise<string> {
272-
function copyDirectoryRecursively(directoryFrom: string, directoryTo: string): Q.Promise<string> {
273-
var promises: Q.Promise<string>[] = [];
271+
public copyTemplate(templatePath: string, projectDirectory: string): Q.Promise<void> {
272+
function copyDirectoryRecursively(directoryFrom: string, directoryTo: string): Q.Promise<void> {
273+
var promises: Q.Promise<void>[] = [];
274274

275275
fs.readdirSync(directoryFrom).forEach(file => {
276276
var fileStats: fs.Stats;
@@ -290,8 +290,8 @@ class RNProjectManager extends ProjectManager {
290290
}
291291
});
292292

293-
// Chain promise so that it maintains Q.Promise<string> type instead of Q.Promise<string[]>
294-
return Q.all<string>(promises).then(() => { return null; });
293+
// Chain promise so that it maintains Q.Promise<void> type instead of Q.Promise<void[]>
294+
return Q.all<void>(promises).then(() => { return null; });
295295
}
296296

297297
return copyDirectoryRecursively(templatePath, path.join(projectDirectory, TestConfig.TestAppName));
@@ -301,15 +301,15 @@ class RNProjectManager extends ProjectManager {
301301
* Creates a new test application at the specified path, and configures it
302302
* with the given server URL, android and ios deployment keys.
303303
*/
304-
public setupProject(projectDirectory: string, templatePath: string, appName: string, appNamespace: string, version?: string): Q.Promise<string> {
304+
public setupProject(projectDirectory: string, templatePath: string, appName: string, appNamespace: string, version?: string): Q.Promise<void> {
305305
if (fs.existsSync(projectDirectory)) {
306306
del.sync([projectDirectory], { force: true });
307307
}
308308
mkdirp.sync(projectDirectory);
309309

310310
return TestUtil.getProcessOutput("react-native init " + appName + " --package " + appNamespace, { cwd: projectDirectory })
311311
.then(this.copyTemplate.bind(this, templatePath, projectDirectory))
312-
.then<string>(TestUtil.getProcessOutput.bind(undefined, "npm install " + TestConfig.thisPluginPath, { cwd: path.join(projectDirectory, TestConfig.TestAppName) }));
312+
.then<void>(TestUtil.getProcessOutput.bind(undefined, "npm install " + TestConfig.thisPluginPath, { cwd: path.join(projectDirectory, TestConfig.TestAppName) })).then(() => { return null; });
313313
}
314314

315315
/** JSON mapping project directories to the current scenario
@@ -335,9 +335,9 @@ class RNProjectManager extends ProjectManager {
335335
/**
336336
* Sets up the scenario for a test in an already existing project.
337337
*/
338-
public setupScenario(projectDirectory: string, appId: string, templatePath: string, jsPath: string, targetPlatform: Platform.IPlatform, version?: string): Q.Promise<string> {
338+
public setupScenario(projectDirectory: string, appId: string, templatePath: string, jsPath: string, targetPlatform: Platform.IPlatform, version?: string): Q.Promise<void> {
339339
// We don't need to anything if it is the current scenario.
340-
if (RNProjectManager.currentScenario[projectDirectory] === jsPath) return Q<string>(undefined);
340+
if (RNProjectManager.currentScenario[projectDirectory] === jsPath) return Q<void>(null);
341341
RNProjectManager.currentScenario[projectDirectory] = jsPath;
342342
RNProjectManager.currentScenarioHasBuilt[projectDirectory] = false;
343343

@@ -354,7 +354,7 @@ class RNProjectManager extends ProjectManager {
354354
.then<void>(TestUtil.replaceString.bind(undefined, destinationIndexPath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName))
355355
.then<void>(TestUtil.replaceString.bind(undefined, destinationIndexPath, TestUtil.SERVER_URL_PLACEHOLDER, targetPlatform.getServerUrl()))
356356
.then<void>(TestUtil.replaceString.bind(undefined, destinationIndexPath, TestUtil.INDEX_JS_PLACEHOLDER, scenarioJs))
357-
.then<string>(TestUtil.replaceString.bind(undefined, destinationIndexPath, TestUtil.CODE_PUSH_APP_VERSION_PLACEHOLDER, version));
357+
.then<void>(TestUtil.replaceString.bind(undefined, destinationIndexPath, TestUtil.CODE_PUSH_APP_VERSION_PLACEHOLDER, version));
358358
}
359359

360360
/**
@@ -390,7 +390,7 @@ class RNProjectManager extends ProjectManager {
390390
/**
391391
* Prepares a specific platform for tests.
392392
*/
393-
public preparePlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<string> {
393+
public preparePlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void> {
394394
var deferred= Q.defer<string>();
395395

396396
var platformsJSONPath = path.join(projectDirectory, RNProjectManager.platformsJSON);
@@ -412,26 +412,26 @@ class RNProjectManager extends ProjectManager {
412412
});
413413

414414
return deferred.promise
415-
.then<string>(() => {
415+
.then<void>(() => {
416416
return (<RNPlatform><any>targetPlatform).installPlatform(projectDirectory);
417417
}, (error: any) => { /* The platform is already installed! */ console.log(error); return null; });
418418
}
419419

420420
/**
421421
* Cleans up a specific platform after tests.
422422
*/
423-
public cleanupAfterPlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<string> {
423+
public cleanupAfterPlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void> {
424424
// Can't uninstall from command line, so noop.
425-
return Q<string>(undefined);
425+
return Q<void>(null);
426426
}
427427

428428
/**
429429
* Runs the test app on the given target / platform.
430430
*/
431-
public runApplication(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<string> {
431+
public runApplication(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void> {
432432
console.log("Running project in " + projectDirectory + " on " + targetPlatform.getName());
433433

434-
return Q<string>(undefined)
434+
return Q<void>(null)
435435
.then(() => {
436436
// Build if this scenario has not yet been built.
437437
if (!RNProjectManager.currentScenarioHasBuilt[projectDirectory]) {
@@ -446,7 +446,7 @@ class RNProjectManager extends ProjectManager {
446446
.then(() => {
447447
// Install and launch the app.
448448
return (<RNPlatform><any>targetPlatform).installApp(projectDirectory)
449-
.then<string>(targetPlatform.getEmulatorManager().launchInstalledApplication.bind(undefined, TestConfig.TestNamespace));
449+
.then<void>(targetPlatform.getEmulatorManager().launchInstalledApplication.bind(undefined, TestConfig.TestNamespace));
450450
});
451451
}
452452
};

0 commit comments

Comments
 (0)