Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove child_process call in gitData before step #4033

Merged
merged 1 commit into from
May 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions packages/cli/test/unit/util/gitData.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import {expect} from "chai";
import child_process from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import findUp from "find-up";
import {gitDataPath, readGitDataFile} from "../../../src/util/gitData/gitDataPath";
import {getGitData} from "../../../src/util";

const WRITE_GIT_DATA_CMD = "npm run write-git-data";

describe("util / gitData", function () {
// In CI, the below before() function takes time
this.timeout(3000);

before(() => {
const pkgJsonPath = findUp.sync("package.json", {cwd: __dirname});
if (!pkgJsonPath) {
throw Error("No package.json found");
}

const pkgJsonDir = path.resolve(path.dirname(pkgJsonPath));
child_process.execSync(WRITE_GIT_DATA_CMD, {cwd: pkgJsonDir});
});

// .gitData file is created at build time with the command
// ```
// npm run write-git-data
// ```
// If this step fails run that command. This could happen when running tests before building.
it("gitData file must exist", () => {
const gitData = readGitDataFile();

Expand Down