Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
fix: print message when installing taking too long
Browse files Browse the repository at this point in the history
  • Loading branch information
phuctm97 committed Jul 3, 2022
1 parent 13be148 commit c0ed568
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -48,6 +48,7 @@
"@tsconfig/node14": "^1.0.1",
"@types/async-retry": "^1.4.4",
"@types/got": "^9.6.12",
"@types/ms": "^0.7.31",
"@types/node": "^14.18.12",
"@types/tar": "^6.1.1",
"async-retry": "^1.3.3",
Expand All @@ -64,5 +65,8 @@
"update-check": "^1.5.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.9.2"
},
"dependencies": {
"ms": "^2.1.3"
}
}
4 changes: 3 additions & 1 deletion src/create.ts
Expand Up @@ -36,10 +36,12 @@ export default async function create(

await formatProject(projectDirectory);

console.log("Installing packages. This might take up to a few minutes.\n");
console.log("Installing packages. This might take up to a few minutes.");

await installDependencies(projectDirectory);

console.log();

if (await tryGitInit(projectDirectory)) {
console.log("Initialized a git repository.\n");
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/install-dependencies.ts
@@ -1,7 +1,13 @@
import ms from "ms";

import { exec } from "./async-exec";

export async function installDependencies(
projectDirectory: string
): Promise<void> {
const internal = setInterval(() => {
console.log("Hang on, packages are still being installed…");
}, ms("5s"));
await exec(`yarn install`, { cwd: projectDirectory });
clearInterval(internal);
}
7 changes: 6 additions & 1 deletion yarn.lock
Expand Up @@ -1044,6 +1044,11 @@
dependencies:
"@types/node" "*"

"@types/ms@^0.7.31":
version "0.7.31"
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197"
integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==

"@types/node-fetch@^2.6.2":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
Expand Down Expand Up @@ -3730,7 +3735,7 @@ ms@2.1.2:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@^2.0.0, ms@^2.1.2:
ms@^2.0.0, ms@^2.1.2, ms@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
Expand Down

0 comments on commit c0ed568

Please sign in to comment.