Skip to content

Commit 5b3c649

Browse files
authored
feat: use OS-specific paths instead of .react-native-cli/cache directory (#1303)
* feat: use OS-specific paths instead of .react-native-cli/cache directory Refs #1202 * fix: fix codestyle * chore: update appdirsjs
1 parent 495d067 commit 5b3c649

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@react-native-community/cli-server-api": "^5.0.1-alpha.0",
3434
"@react-native-community/cli-tools": "^5.0.1-alpha.0",
3535
"@react-native-community/cli-types": "^5.0.1-alpha.0",
36+
"appdirsjs": "^1.2.4",
3637
"chalk": "^3.0.0",
3738
"command-exists": "^1.2.8",
3839
"commander": "^2.19.0",

packages/cli/src/tools/releaseChecker/releaseCacheManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
22
import fs from 'fs';
33
import os from 'os';
4+
import appDirs from 'appdirsjs';
45
import mkdirp from 'mkdirp';
56
import {logger} from '@react-native-community/cli-tools';
67

@@ -38,7 +39,9 @@ function saveCache(name: string, cache: Cache) {
3839
* In case it doesn't exist, it will be created.
3940
*/
4041
function getCacheRootPath() {
41-
const cachePath = path.resolve(os.homedir(), '.react-native-cli', 'cache');
42+
const legacyPath = path.resolve(os.homedir(), '.react-native-cli', 'cache');
43+
const cachePath = appDirs({appName: 'react-native-cli', legacyPath}).cache;
44+
4245
if (!fs.existsSync(cachePath)) {
4346
mkdirp.sync(cachePath);
4447
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,11 @@ anymatch@^3.0.3, anymatch@~3.1.1:
28052805
normalize-path "^3.0.0"
28062806
picomatch "^2.0.4"
28072807

2808+
appdirsjs@^1.2.3:
2809+
version "1.2.4"
2810+
resolved "https://registry.yarnpkg.com/appdirsjs/-/appdirsjs-1.2.4.tgz#3ab582acc9fdfaaa0c1f81b3a25422ad4d95f9d4"
2811+
integrity sha512-WO5StDORR6JF/xYnXk/Fm0yu+iULaV5ULKuUw0Tu+jbgiTlSquaWBCgbpnsHLMXldf+fM3Gxn5p7vjond7He6w==
2812+
28082813
aproba@^1.0.3, aproba@^1.1.1:
28092814
version "1.2.0"
28102815
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"

0 commit comments

Comments
 (0)