-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 merge remote-tracking branch 'origin/master' into antoinekm/workshop
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,48 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const spawn = require("cross-spawn"); | ||
const merge = require("merge-stream"); | ||
|
||
const env = { ...process.env, FORCE_COLOR: true }; | ||
|
||
const devPackages = spawn("pnpm", ["dev:packages"], { | ||
stdio: "pipe", | ||
env, | ||
}); | ||
|
||
const devApps = () => spawn("pnpm", ["dev:apps"], { stdio: "pipe", env }); | ||
|
||
const waitForSuccess = (stream) => { | ||
return new Promise((resolve) => { | ||
stream.on("data", (data) => { | ||
const output = data.toString(); | ||
console.log(output); | ||
if ( | ||
output.includes("info") && | ||
output.includes("waiting for changes...") | ||
) { | ||
stream.removeAllListeners("data"); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
devPackages.stderr.on("data", (data) => { | ||
console.error(data.toString()); | ||
}); | ||
|
||
devPackages.on("exit", (code) => { | ||
console.log(`dev:packages exited with code ${code}`); | ||
}); | ||
|
||
waitForSuccess(devPackages.stdout).then(() => { | ||
const devAppsProcess = devApps(); | ||
const mergedOutput = merge(devPackages.stdout, devAppsProcess.stdout); | ||
mergedOutput.on("data", (data) => { | ||
console.log(data.toString()); | ||
}); | ||
const mergedError = merge(devPackages.stderr, devAppsProcess.stderr); | ||
mergedError.on("data", (data) => { | ||
console.error(data.toString()); | ||
}); | ||
}); |