Commit e0f67e0
fix: set project directory to install packages in init command (#262)
Fixes #260 and facebook/react-native#24103 by setting project directory on PackageManager which is needed to check for yarn.lock file.
Summary:
---------
I'm not sure how to test this but creating new projects fail with the exception
```
info Adding required dependencies
internal/validators.js:125
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.join (path.js:1147:7)
at isProjectUsingYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/yarn.js:101:51)
at shouldUseYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:36:39)
at Object.install (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:44:10)
at generateProject (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:111:18)
at Object.init (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:94:3)
at run (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:302:7)
at createProject (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:249:3)
at init (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:200:5)
```
The error seems to be stemming from passing `undefined` for `projectDir` to `path.join`. Added a line to fix this.
Test Plan:
----------
`react-native init TestProject` should not fail.1 parent 35ecc18 commit e0f67e0
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
0 commit comments