Skip to content

Commit

Permalink
Merge pull request #55 from anulman/refactor/installer-errors
Browse files Browse the repository at this point in the history
refactor(installer): return more-helpful error message on fakeroot ENOENT
  • Loading branch information
unindented committed Mar 26, 2017
2 parents 720592b + 0d8feff commit e5a0ae1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/installer.js
Expand Up @@ -44,6 +44,18 @@ var spawn = function (options, command, args, callback) {
})

spawnedProcess.on('error', function (err) {
if (err.name === 'ENOENT') {
var isFakeroot = err.syscall === 'spawn fakeroot'
var isDpkg = !isFakeroot && err.syscall === 'spawn dpkg'

if (isFakeroot || isDpkg) {
var installer = process.platform === 'darwin' ? 'brew' : 'apt-get'
var pkg = isFakeroot ? 'fakeroot' : 'dpkg'

err.message = 'Your system is missing the fakeroot package. Try e.g. `' + installer + ' install ' + pkg + '`'
}
}

error = error || err
})

Expand Down

0 comments on commit e5a0ae1

Please sign in to comment.