Skip to content

Commit 381a7c1

Browse files
bebrawKent C. Dodds
authored and
Kent C. Dodds
committed
fix: fix exposed API (#119 regression)
It should expose a function like before now. The previous commit changed it to export an object accidentally and this commit restores the old behavior.
1 parent 19d2f35 commit 381a7c1

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/bin/validate-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
const validate = require('../index').validateRoot
2+
const validate = require('../').validateRoot
33
const argv = require('yargs').argv
44

55
module.exports = function validateConfig(webpackConfigFile, quiet) {

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ function validate(config, options) {
9393
return config
9494
}
9595

96+
module.exports = validate
97+
9698
// Easier consumability for require (default use case for non-transpiled webpack configs)
9799
function validateRoot(config, options = {}) {
98100
const {
@@ -120,6 +122,5 @@ function validateRoot(config, options = {}) {
120122
return validationResult || multiValidationResults
121123
}
122124

123-
exports.validate = validate
124-
exports.validateRoot = validateRoot
125-
exports.Joi = Joi
125+
module.exports.validateRoot = validateRoot
126+
module.exports.Joi = Joi

src/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import sinon from 'sinon'
22
import configs from '../test/passing-configs'
33
import failingConfigs from '../test/failing-configs'
4-
import { Joi } from './'
5-
6-
const validate = require('./index').validateRoot
4+
import { validateRoot as validate, Joi } from './'
75

86
describe('.', () => {
97
let sandbox

test/utils/allInvalid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk'
22
import util from 'util'
3-
import { validate } from '../../src'
3+
import validate from '../../src'
44

55
/**
66
* For all supplied configs (array of objects), check that they are invalid given a schema.

test/utils/allValid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk'
22
import util from 'util'
3-
import { validate } from '../../src'
3+
import validate from '../../src'
44

55
/**
66
* For all supplied configs (array of objects), check that they are valid given a schema.

0 commit comments

Comments
 (0)