forked from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
991af11
commit 4bec81e
Showing
5 changed files
with
64 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-eth": patch | ||
--- | ||
|
||
cli: show yarn install ouput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,7 @@ | |
"inquirer": "9.2.0", | ||
"listr2": "^8.2.1", | ||
"merge-packages": "^0.1.6", | ||
"ncp": "2.0.0", | ||
"pkg-install": "1.0.0" | ||
"ncp": "2.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,52 @@ | ||
import { projectInstall } from "pkg-install"; | ||
import { DefaultRenderer, ListrTaskWrapper, SimpleRenderer } from "listr2"; | ||
import { execaCommand } from "execa"; | ||
import chalk from "chalk"; | ||
|
||
export function installPackages(targetDir: string) { | ||
return projectInstall({ | ||
cwd: targetDir, | ||
prefer: "yarn", | ||
export async function installPackages( | ||
targetDir: string, | ||
task: ListrTaskWrapper<any, typeof DefaultRenderer, typeof SimpleRenderer>, | ||
) { | ||
const execute = execaCommand("yarn install", { cwd: targetDir }); | ||
|
||
let outputBuffer: string = ""; | ||
|
||
const chunkSize = 1024; | ||
execute?.stdout?.on("data", (data: Buffer) => { | ||
outputBuffer += data.toString(); | ||
|
||
if (outputBuffer.length > chunkSize) { | ||
outputBuffer = outputBuffer.slice(-1 * chunkSize); | ||
} | ||
|
||
const visibleOutput = | ||
outputBuffer | ||
.match(new RegExp(`.{1,${chunkSize}}`, "g")) | ||
?.slice(-1) | ||
.map(chunk => chunk.trimEnd() + "\n") | ||
.join("") ?? outputBuffer; | ||
|
||
task.output = visibleOutput; | ||
if (visibleOutput.includes("Link step")) { | ||
task.output = chalk.yellow(`starting link step, this might take a little time...`); | ||
} | ||
}); | ||
|
||
execute?.stderr?.on("data", (data: Buffer) => { | ||
outputBuffer += data.toString(); | ||
|
||
if (outputBuffer.length > chunkSize) { | ||
outputBuffer = outputBuffer.slice(-1 * chunkSize); | ||
} | ||
|
||
const visibleOutput = | ||
outputBuffer | ||
.match(new RegExp(`.{1,${chunkSize}}`, "g")) | ||
?.slice(-1) | ||
.map(chunk => chunk.trimEnd() + "\n") | ||
.join("") ?? outputBuffer; | ||
|
||
task.output = visibleOutput; | ||
}); | ||
|
||
await execute; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters