-
Notifications
You must be signed in to change notification settings - Fork 31
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
eb6e440
commit 07c8d34
Showing
2 changed files
with
53 additions
and
33 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
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,4 +1,4 @@ | ||
import { execSync } from "node:child_process"; | ||
import { execSync, spawn } from "node:child_process"; | ||
import tar from "tar"; | ||
import { mkdir, readFile, readdir, copyFile, rm } from "fs/promises"; | ||
|
||
|
@@ -10,11 +10,15 @@ const run = (...args: Parameters<typeof execSync>) => { | |
|
||
const main = async () => { | ||
run("npm run prepublishOnly"); | ||
|
||
// Simulates publishing to npm | ||
// and includes only the files that would be published | ||
run("npm pack"); | ||
|
||
await mkdir("e2e"); | ||
|
||
await extractPackage(); | ||
|
||
if (process.env.CI === "true") { | ||
run(`git config --global user.email "[email protected]"`, { | ||
cwd: "e2e", | ||
|
@@ -23,16 +27,19 @@ const main = async () => { | |
cwd: "e2e", | ||
}); | ||
} | ||
run("echo ./installation | ./package/bin.js", { | ||
cwd: "e2e", | ||
}); | ||
|
||
await install(); | ||
|
||
run("npm run postpublish"); | ||
|
||
await Promise.all( | ||
["graph", "concrete", "foundation"].map(copyExerciseAnswers) | ||
); | ||
|
||
run("npm run check -- --run", { | ||
cwd: "e2e/installation", | ||
}); | ||
|
||
rm("e2e", { recursive: true, force: true }); | ||
}; | ||
|
||
|
@@ -50,6 +57,27 @@ const extractPackage = async () => { | |
}); | ||
}; | ||
|
||
const install = async () => { | ||
// For some reason piping stuff with echo | ||
// doesn't work properly with Windows | ||
|
||
const process = spawn("node ./package/bin.js", { | ||
stdio: ["pipe", "inherit", "inherit"], | ||
cwd: "e2e", | ||
shell: true, | ||
}); | ||
|
||
await new Promise((resolve) => { | ||
process.on("spawn", resolve); | ||
}); | ||
|
||
process.stdin.write("installation\n"); | ||
|
||
await new Promise((resolve) => { | ||
process.on("exit", resolve); | ||
}); | ||
}; | ||
|
||
const copyExerciseAnswers = async (category: string) => { | ||
const exercises = await readdir(`./src/exercises/${category}`); | ||
|
||
|