forked from taskrabbit/ReactNativeSampleApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRunnerManager.m
More file actions
43 lines (32 loc) · 1.13 KB
/
Copy pathTestRunnerManager.m
File metadata and controls
43 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// TestRunnerManager.m
// Tasker
//
// Created by Brian Leonard on 8/9/15.
// Copyright (c) 2015 TaskRabbit. All rights reserved.
//
#import "RCTBridgeModule.h"
#import "RCTBridge.h"
@interface TestRunnerManager : NSObject <RCTBridgeModule>
@end
@implementation TestRunnerManager
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(reset:(RCTResponseSenderBlock)callback)
{
// delete all data in documents directory
NSString *folderPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSError *error = nil;
for (NSString *file in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error]) {
// If you want to skip certain files
if ([file containsString:@".skip"]) {
// but be sure to clear them out if applicable from your js code
continue;
}
// otherwise, delete
[[NSFileManager defaultManager] removeItemAtPath:[folderPath stringByAppendingPathComponent:file] error:&error];
}
// reload the app
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil userInfo:nil];
callback(@[]);
}
@end