forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-e2e-local-clean.js
73 lines (61 loc) · 2.2 KB
/
test-e2e-local-clean.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
/*
* This script, paired with test-e2e-local.js, is the full suite of
* tooling needed for a successful local testing experience.
* This script is an helper to clean up the environment fully
* before running the test suite.
*
* You should use this when switching between branches.
*
* It will:
* - clean up node modules
* - clean up the build folder (derived data, gradlew clean)
* - clean up the pods folder for RNTester (pod install) (and Podfile.lock too)
* - kill all packagers
* - remove RNTestProject folder
*
* an improvements to consider:
* - an option to uninstall the apps (RNTester, RNTestProject) from emulators
*/
const {isPackagerRunning} = require('./testing-utils');
const {exec, exit} = require('shelljs');
console.info('\n** Starting the clean up process **\n');
// let's check if Metro is already running, if it is let's kill it and start fresh
if (isPackagerRunning() === 'running') {
exec("lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill");
console.info('\n** Killed Metro **\n');
}
// Android
console.info('\n** Cleaning Gradle build artifacts **\n');
exec('./gradlew clean');
exec('rm -rf /tmp/maven-local');
exec('rm -rf /tmp/react-native-tmp');
// iOS
console.info('\n** Nuking the derived data folder **\n');
exec('rm -rf ~/Library/Developer/Xcode/DerivedData');
console.info('\n** Removing the hermes-engine pod cache **\n');
exec('rm -rf ~/Library/Caches/CocoaPods/Pods/External/hermes-engine');
// RNTester Pods
console.info('\n** Removing the RNTester Pods **\n');
exec('rm -rf packages/rn-tester/Pods');
// RNTestProject
console.info('\n** Removing the RNTestProject folder **\n');
exec('rm -rf /tmp/RNTestProject');
// final clean up
console.info('\n** Final git level wipe **\n');
// clean unstaged changes from git
exec('git checkout -- .');
// remove all the untracked files
exec('git clean -fdx');
console.info(
'\n** Clean up process completed\nPlease remember to run yarn install if you are planning to test again\n',
);
exit(0);