Skip to content

Commit

Permalink
Add promise support to api
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Nov 1, 2020
1 parent fe50723 commit d67f191
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const deglob = require('deglob')
const find = require('find-file-up')
const engine = require('unified-engine')
const color = require('supports-color').stdout
const fromCallback = require('catering').fromCallback
const processor = require('remark')
const path = require('path')
const fs = require('fs')

function hallmark (options, callback) {
callback = fromCallback(callback)

const fix = !!options.fix
const cwd = path.resolve(options.cwd || '.')
const pkg = read('package.json', cwd) || {}
Expand Down Expand Up @@ -108,6 +111,8 @@ function hallmark (options, callback) {
callback(null, { code, files: context.files })
})
})

return callback.promise
}

exports.lint = function (options, callback) {
Expand All @@ -116,7 +121,7 @@ exports.lint = function (options, callback) {
options = {}
}

hallmark({ ...options, fix: false }, callback)
return hallmark({ ...options, fix: false }, callback)
}

exports.fix = function (options, callback) {
Expand All @@ -125,7 +130,7 @@ exports.fix = function (options, callback) {
options = {}
}

hallmark({ ...options, fix: true }, callback)
return hallmark({ ...options, fix: true }, callback)
}

exports.bump = function (target, options, callback) {
Expand All @@ -138,14 +143,16 @@ exports.bump = function (target, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
} else if (options == null) {
options = {}
}

const changelog = {
...options.changelog,
add: target
}

hallmark({ ...options, changelog, fix: true }, callback)
return hallmark({ ...options, changelog, fix: true }, callback)
}

function read (file, cwd) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"USAGE"
],
"dependencies": {
"catering": "^2.0.0",
"deglob": "^4.0.0",
"find-file-up": "^2.0.1",
"github-url-from-git": "^1.5.0",
Expand Down

0 comments on commit d67f191

Please sign in to comment.