Skip to content

Commit

Permalink
Test for build removes contents of build directory before script is run
Browse files Browse the repository at this point in the history
  • Loading branch information
ty2k committed Aug 19, 2024
1 parent da46f8c commit 12c5f8f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/design-tokens/build-output.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import assert from "node:assert";
test("build-output.js should complete without errors", async () => {
try {
await new Promise((resolve, reject) => {
// Execute the build script using Node.js
exec("node build-output.js", (error, stdout, stderr) => {
// If there was an error, the test should fail
if (error) {
console.error("Error executing build-output.js:", stderr);
return reject(new Error("build-output.js threw an error"));
// Execute the `build` script from package.json, removing the build
// directory contents before running build-output.js.
exec(
"rm -rf build/cjs* && rm -rf build/css* && rm -rf build/js* && node build-output.js",
(error, stdout, stderr) => {
// If there was an error, the test should fail.
if (error) {
console.error("Error executing build-output.js:", stderr);
return reject(new Error("build-output.js threw an error"));
}
console.log("build-output.js executed successfully:", stdout);
resolve();
}
console.log("build-output.js executed successfully:", stdout);
resolve();
});
);
});
assert.ok(true);
} catch (error) {
Expand Down

0 comments on commit 12c5f8f

Please sign in to comment.