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
|
||||
.tsbuildinfo
|
||||
__tests__
|
||||
node_modules
|
||||
|
||||
# Files in the templates need to stay
|
||||
/tsconfig*
|
||||
|
|
|
@ -270,23 +270,18 @@ export default async function init(
|
|||
|
||||
const pkgManager = useYarn ? 'yarn' : 'npm';
|
||||
// Display the most elegant way to cd.
|
||||
const cdpath =
|
||||
path.join(process.cwd(), name) === dest
|
||||
? name
|
||||
: path.relative(process.cwd(), name);
|
||||
const cdpath = path.relative('.', dest);
|
||||
if (!cliOptions.skipInstall) {
|
||||
shell.cd(dest);
|
||||
logger.info`Installing dependencies with name=${pkgManager}...`;
|
||||
if (
|
||||
shell.exec(
|
||||
`cd "${name}" && ${useYarn ? 'yarn' : 'npm install --color always'}`,
|
||||
{
|
||||
shell.exec(useYarn ? 'yarn' : 'npm install --color always', {
|
||||
env: {
|
||||
...process.env,
|
||||
// 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.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