mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
fix(init): cd to correct path when installing (#6468)
* [bug] ensure we use the correct cd path * Update index.ts * refactor * add ignore Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
dd539dd23f
commit
d73b4f8674
2 changed files with 9 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
||||||
copyUntypedFiles.mjs
|
copyUntypedFiles.mjs
|
||||||
.tsbuildinfo
|
.tsbuildinfo
|
||||||
__tests__
|
__tests__
|
||||||
|
node_modules
|
||||||
|
|
||||||
# Files in the templates need to stay
|
# Files in the templates need to stay
|
||||||
/tsconfig*
|
/tsconfig*
|
||||||
|
|
|
@ -270,23 +270,18 @@ export default async function init(
|
||||||
|
|
||||||
const pkgManager = useYarn ? 'yarn' : 'npm';
|
const pkgManager = useYarn ? 'yarn' : 'npm';
|
||||||
// Display the most elegant way to cd.
|
// Display the most elegant way to cd.
|
||||||
const cdpath =
|
const cdpath = path.relative('.', dest);
|
||||||
path.join(process.cwd(), name) === dest
|
|
||||||
? name
|
|
||||||
: path.relative(process.cwd(), name);
|
|
||||||
if (!cliOptions.skipInstall) {
|
if (!cliOptions.skipInstall) {
|
||||||
|
shell.cd(dest);
|
||||||
logger.info`Installing dependencies with name=${pkgManager}...`;
|
logger.info`Installing dependencies with name=${pkgManager}...`;
|
||||||
if (
|
if (
|
||||||
shell.exec(
|
shell.exec(useYarn ? 'yarn' : 'npm install --color always', {
|
||||||
`cd "${name}" && ${useYarn ? 'yarn' : 'npm install --color always'}`,
|
env: {
|
||||||
{
|
...process.env,
|
||||||
env: {
|
// Force coloring the output, since the command is invoked by shelljs, which is not the interactive shell
|
||||||
...process.env,
|
...(supportsColor.stdout ? {FORCE_COLOR: '1'} : {}),
|
||||||
// Force coloring the output, since the command is invoked by shelljs, which is not the interactive shell
|
|
||||||
...(supportsColor.stdout ? {FORCE_COLOR: '1'} : {}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
).code !== 0
|
}).code !== 0
|
||||||
) {
|
) {
|
||||||
logger.error('Dependency installation failed.');
|
logger.error('Dependency installation failed.');
|
||||||
logger.info`The site directory has already been created, and you can retry by typing:
|
logger.info`The site directory has already been created, and you can retry by typing:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue