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

Replace cosmiconfig with lilconfig #283

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 0 additions & 13 deletions cli/test/config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ describe('config', () => {
assert.equals(json.tests[0].fullTitle, 'test passes');
});

it('custom.config.yaml', async () => {
const result = await execa(
'../../index.js',
['--config', 'custom.config.yaml', 'passes.js'],
{
cwd: path.join(__dirname, 'fixture'),
stderr: process.stderr
}
);

assert.match(result.stdout, 'ok 1 test passes');
});

it('overrides config with command line option', async () => {
const result = await execa(
'../../index.js',
Expand Down
4 changes: 2 additions & 2 deletions mochify/lib/load-config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const deepmerge = require('deepmerge');
const { cosmiconfig } = require('cosmiconfig');
const { lilconfig } = require('lilconfig');

exports.loadConfig = loadConfig;

async function loadConfig(options) {
const explorer = cosmiconfig('mochify');
const explorer = lilconfig('mochify');

const default_config_promise = explorer.search();

Expand Down
26 changes: 13 additions & 13 deletions mochify/lib/load-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ const proxyquire = require('proxyquire');
const { assert, refute, sinon } = require('@sinonjs/referee-sinon');

describe('mochify/lib/load-config', () => {
let cosmiconfig_api;
let cosmiconfig;
let lilconfig_api;
let lilconfig;

beforeEach(() => {
cosmiconfig_api = {
lilconfig_api = {
search: sinon.fake.resolves(null),
load: sinon.fake.resolves(null)
};
cosmiconfig = sinon.fake.returns(cosmiconfig_api);
lilconfig = sinon.fake.returns(lilconfig_api);
});

function requireLoadConfig() {
const { loadConfig } = proxyquire('./load-config', {
cosmiconfig: {
cosmiconfig
lilconfig: {
lilconfig
}
});
return loadConfig;
}

function setDefaultConfig(config) {
sinon.replace(cosmiconfig_api, 'search', sinon.fake.resolves({ config }));
sinon.replace(lilconfig_api, 'search', sinon.fake.resolves({ config }));
}

function setSpecifiedConfig(config) {
sinon.replace(cosmiconfig_api, 'load', sinon.fake.resolves({ config }));
sinon.replace(lilconfig_api, 'load', sinon.fake.resolves({ config }));
}

it('searches for default config only', async () => {
Expand All @@ -38,9 +38,9 @@ describe('mochify/lib/load-config', () => {
const promise = loadConfig({});

await assert.resolves(promise);
assert.calledOnceWithExactly(cosmiconfig, 'mochify');
assert.calledOnceWithExactly(cosmiconfig_api.search);
refute.called(cosmiconfig_api.load);
assert.calledOnceWithExactly(lilconfig, 'mochify');
assert.calledOnceWithExactly(lilconfig_api.search);
refute.called(lilconfig_api.load);
});

it('returns given options', async () => {
Expand Down Expand Up @@ -112,8 +112,8 @@ describe('mochify/lib/load-config', () => {
config: 'some.config.js',
reporter: 'dot'
});
assert.calledOnceWithExactly(cosmiconfig_api.search);
assert.calledOnceWithExactly(cosmiconfig_api.load, 'some.config.js');
assert.calledOnceWithExactly(lilconfig_api.search);
assert.calledOnceWithExactly(lilconfig_api.load, 'some.config.js');
});

it('options override specified config', async () => {
Expand Down
2 changes: 1 addition & 1 deletion mochify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
},
"dependencies": {
"convert-source-map": "^1.1.3",
"cosmiconfig": "^7.0.0",
"deepmerge": "^4.2.2",
"execa": "^5.1.1",
"glob": "^7.1.7",
"lilconfig": "^3.0.0",
"mime": "^2.5.2",
"mocha": "^10.2.0",
"source-map": "^0.5.7",
Expand Down
Loading
Loading