Skip to content

Commit

Permalink
Remove child_process call in gitData before step
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed May 18, 2022
1 parent 01e6ffe commit 41de0f0
Showing 1 changed file with 5 additions and 16 deletions.
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

0 comments on commit 41de0f0

Please sign in to comment.