Make `execDependencyGraph` a CommonJS module (#767)
Summary: This simplifies interfaces everywhere. See also #216, which did the opposite of this as a temporary fix due to a Babel/Webpack interaction that no longer exists as of #766. Test Plan: Note that `node bin/sourcecred.js load sourcecred/example-git` still works (after `yarn backend`). Note that `yarn test` still works. These demonstrate that the module works from both a Webpack context and a Node context. Note that `git grep --name-only execDependencyGraph` yields exactly those files touched in this commit. Note that `yarn test --full` passes. wchargin-branch: commonjs-execDependencyGraph
This commit is contained in:
parent
9b31905ab4
commit
5e0833421a
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
const execDependencyGraph = require("../src/tools/execDependencyGraph").default;
|
const execDependencyGraph = require("../src/tools/execDependencyGraph");
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ import dedent from "../util/dedent";
|
||||||
import type {Command} from "./command";
|
import type {Command} from "./command";
|
||||||
import * as Common from "./common";
|
import * as Common from "./common";
|
||||||
|
|
||||||
|
import execDependencyGraph from "../tools/execDependencyGraph";
|
||||||
import {loadGithubData} from "../plugins/github/loadGithubData";
|
import {loadGithubData} from "../plugins/github/loadGithubData";
|
||||||
import {loadGitData} from "../plugins/git/loadGitData";
|
import {loadGitData} from "../plugins/git/loadGitData";
|
||||||
|
|
||||||
const execDependencyGraph = require("../tools/execDependencyGraph").default;
|
|
||||||
|
|
||||||
function usage(print: (string) => void): void {
|
function usage(print: (string) => void): void {
|
||||||
print(
|
print(
|
||||||
dedent`\
|
dedent`\
|
||||||
|
|
|
@ -10,9 +10,7 @@ import load, {help} from "./load";
|
||||||
import * as RepoRegistry from "../app/credExplorer/repoRegistry";
|
import * as RepoRegistry from "../app/credExplorer/repoRegistry";
|
||||||
import {stringToRepo} from "../core/repo";
|
import {stringToRepo} from "../core/repo";
|
||||||
|
|
||||||
jest.mock("../tools/execDependencyGraph", () => ({
|
jest.mock("../tools/execDependencyGraph", () => jest.fn());
|
||||||
default: jest.fn(),
|
|
||||||
}));
|
|
||||||
jest.mock("../plugins/github/loadGithubData", () => ({
|
jest.mock("../plugins/github/loadGithubData", () => ({
|
||||||
loadGithubData: jest.fn(),
|
loadGithubData: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
@ -21,8 +19,7 @@ jest.mock("../plugins/git/loadGitData", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
type JestMockFn = $Call<typeof jest.fn>;
|
type JestMockFn = $Call<typeof jest.fn>;
|
||||||
const execDependencyGraph: JestMockFn = (require("../tools/execDependencyGraph")
|
const execDependencyGraph: JestMockFn = (require("../tools/execDependencyGraph"): any);
|
||||||
.default: any);
|
|
||||||
const loadGithubData: JestMockFn = (require("../plugins/github/loadGithubData")
|
const loadGithubData: JestMockFn = (require("../plugins/github/loadGithubData")
|
||||||
.loadGithubData: any);
|
.loadGithubData: any);
|
||||||
const loadGitData: JestMockFn = (require("../plugins/git/loadGitData")
|
const loadGitData: JestMockFn = (require("../plugins/git/loadGitData")
|
||||||
|
|
|
@ -48,7 +48,7 @@ const defaultOptions = {
|
||||||
overallFailLabel: "FAILURE",
|
overallFailLabel: "FAILURE",
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.default = async function execDependencyGraph(
|
module.exports = async function execDependencyGraph(
|
||||||
tasks /*: $ReadOnlyArray<Task> */,
|
tasks /*: $ReadOnlyArray<Task> */,
|
||||||
options /*:: ?: RunOptions */
|
options /*:: ?: RunOptions */
|
||||||
) /*: Promise<OverallResult> */ {
|
) /*: Promise<OverallResult> */ {
|
||||||
|
|
Loading…
Reference in New Issue