mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 23:59:42 +08:00
add tests
This commit is contained in:
@@ -14,7 +14,12 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
|
||||
+ (NSString *)getCodePushPath
|
||||
{
|
||||
return [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
|
||||
NSString* codePushPath = [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
|
||||
if ([CodePush isUsingTestConfiguration]) {
|
||||
codePushPath = [codePushPath stringByAppendingPathComponent:@"TestPackages"];
|
||||
}
|
||||
|
||||
return codePushPath;
|
||||
}
|
||||
|
||||
+ (NSString *)getDownloadFilePath
|
||||
@@ -481,4 +486,31 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
[self updateCurrentPackageInfo:info error:&error];
|
||||
}
|
||||
|
||||
+ (void)downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl
|
||||
{
|
||||
NSURL *urlRequest = [NSURL URLWithString:remoteBundleUrl];
|
||||
NSError *error = nil;
|
||||
NSString *downloadedBundle = [NSString stringWithContentsOfURL:urlRequest
|
||||
encoding:NSUTF8StringEncoding
|
||||
error:&error];
|
||||
|
||||
if (error) {
|
||||
NSLog(@"Error downloading from URL %@", remoteBundleUrl);
|
||||
} else {
|
||||
NSString *currentPackageBundlePath = [self getCurrentPackageBundlePath:&error];
|
||||
[downloadedBundle writeToFile:currentPackageBundlePath
|
||||
atomically:YES
|
||||
encoding:NSUTF8StringEncoding
|
||||
error:&error];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)clearTestUpdates
|
||||
{
|
||||
if ([CodePush isUsingTestConfiguration]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[self getCodePushPath] error:nil];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[self getStatusFilePath] error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user