Make loadPartialConfig's options optional (#12200)
This commit is contained in:
parent
47250ffa65
commit
31396b286d
@ -157,8 +157,14 @@ type LoadPartialConfigOpts = {
|
||||
};
|
||||
|
||||
export const loadPartialConfig = gensync<[any], PartialConfig | null>(
|
||||
function* (inputOpts: LoadPartialConfigOpts): Handler<PartialConfig | null> {
|
||||
const { showIgnoredFiles, ...opts } = inputOpts;
|
||||
function* (opts?: LoadPartialConfigOpts): Handler<PartialConfig | null> {
|
||||
let showIgnoredFiles = false;
|
||||
// We only extract showIgnoredFiles if opts is an object, so that
|
||||
// loadPrivatePartialConfig can throw the appropriate error if it's not.
|
||||
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
|
||||
({ showIgnoredFiles, ...opts } = opts);
|
||||
}
|
||||
|
||||
const result: ?PrivPartialConfig = yield* loadPrivatePartialConfig(opts);
|
||||
if (!result) return null;
|
||||
|
||||
|
||||
@ -1330,6 +1330,17 @@ describe("buildConfigChain", function () {
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
it("loadPartialConfig can be called with no arguments", () => {
|
||||
const cwd = process.cwd();
|
||||
|
||||
try {
|
||||
process.chdir(fixture("config-files", "babelrc-extended"));
|
||||
expect(() => babel.loadPartialConfig()).not.toThrow();
|
||||
} finally {
|
||||
process.chdir(cwd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should throw when `test` presents but `filename` is not passed", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user