Skip to content

Commit

Permalink
Deprecate the callback version of the packager API (#837)
Browse files Browse the repository at this point in the history
Ignore the warning in code coverage
  • Loading branch information
malept committed May 3, 2018
1 parent 28d9dde commit a43c90c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cli.js
Expand Up @@ -38,13 +38,13 @@ if (args.help) {
printUsageAndExit(true)
}

packager(args, function done (err, appPaths) {
if (err) {
packager(args)
.then(function done (appPaths) {
if (appPaths.length > 1) console.error('Wrote new apps to:\n' + appPaths.join('\n'))
else if (appPaths.length === 1) console.error('Wrote new app to', appPaths[0])
return true
}).catch(function error (err) {
if (err.message) console.error(err.message)
else console.error(err, err.stack)
process.exit(1)
}

if (appPaths.length > 1) console.error('Wrote new apps to:\n' + appPaths.join('\n'))
else if (appPaths.length === 1) console.error('Wrote new app to', appPaths[0])
})
})
10 changes: 5 additions & 5 deletions docs/api.md
@@ -1,18 +1,18 @@
# electron-packager API

Short [callback](#callback) example:
Short Promise example:

```javascript
const packager = require('electron-packager')
packager(options, function done_callback (err, appPaths) { /**/ })
packager(options)
.then(appPaths => { /**/ })
```

Short Promise example:
Short [(deprecated) callback syntax](#callback) example:

```javascript
const packager = require('electron-packager')
packager(options)
.then((appPaths) => { /**/ })
packager(options, function done_callback (err, appPaths) { /**/ })
```

## `options`
Expand Down
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -180,5 +180,9 @@ function packagerPromise (opts) {
}

module.exports = function packager (opts, cb) {
if (cb) {
/* istanbul ignore next */
common.warning('The callback-based version of packager() is deprecated and will be removed in a future major version, please convert to the Promise version or use the nodeify module.')
}
return nodeify(packagerPromise(opts), cb)
}

0 comments on commit a43c90c

Please sign in to comment.