Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
fix function name and docs (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm authored May 21, 2019
1 parent f8d5b1b commit 19618b0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ const packageCompliant = require('package-compliant')
const aPackageJson = require('./package.json')

try {
packageCompliant.validatePackageJson(aPackageJson)
packageCompliant.validateSupportField(aPackageJson.support)
// the package is valid
} catch (err) {
// the package has some errors
}

// or you can use callback:
packageCompliant.validatePackageJson(aPackageJson, (err, valid) => {
packageCompliant.validateSupportField(aPackageJson.support, (err, valid) => {
if (err) {
// there are some errors!!
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

// this file is the main interface to use this package as a module

module.exports.validatePackageJson = require('./support-validation')
module.exports.validateSupportField = require('./support-validation')
6 changes: 3 additions & 3 deletions lib/support-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const validate = ajv.compile(supportSchema)
/**
* Validate the package.json agains a JSON schema.
* If a callback isn't provided, an error will be thrown if the json isn't valid.
* @param {object} packageJson a package.json object
* @param {object} packageJson.support a package.json object
* @param {function} cb an optional callback <Error[], boolean>
*/
function validatePackageJson (packageJson, cb) {
function validateSupportField (packageJson, cb) {
const valid = validate(packageJson)
if (cb) {
cb(validate.errors, valid)
Expand All @@ -26,4 +26,4 @@ function validatePackageJson (packageJson, cb) {
}
}

module.exports = validatePackageJson
module.exports = validateSupportField
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
"type": "git",
"url": "git+https://github.com/Eomm/package-compliant.git"
},
"keywords": [],
"keywords": [
"package",
"package-json",
"validation",
"support"
],
"author": "Manuel Spigolon <[email protected]> (https://github.com/Eomm)",
"license": "MIT",
"bugs": {
Expand All @@ -38,4 +43,4 @@
"standard": "^12.0.1",
"tap": "^12.6.3"
}
}
}
4 changes: 2 additions & 2 deletions test/public-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const t = require('tap')
const publicApi = require('../lib/index')
const test = t.test

test('validatePackageJson function', t => {
test('validateSupportField function', t => {
t.plan(1)
const func = publicApi.validatePackageJson
const func = publicApi.validateSupportField
t.type(func, 'function')
})

0 comments on commit 19618b0

Please sign in to comment.