From 7949296cec9fce200a53e3ec51ca131955852d2d Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 29 Jan 2015 10:39:12 -0400 Subject: [PATCH] Extend EACCESS, EPERM errors with OS specific descriptions --- lib/errors/errors.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/errors/errors.coffee b/lib/errors/errors.coffee index a9a8541b..bc50f743 100644 --- a/lib/errors/errors.coffee +++ b/lib/errors/errors.coffee @@ -1,4 +1,5 @@ _ = require('lodash') +os = require('os') exports.handle = (error, exit = true) -> return if not error? or error not instanceof Error @@ -13,7 +14,14 @@ exports.handle = (error, exit = true) -> console.error("No such file or directory: #{error.path}") else if error.code is 'EACCES' or error.code is 'EPERM' - console.error('You don\'t have enough privileges to run this operation.') + message = 'You don\'t have enough privileges to run this operation.\n' + + if os.platform() is 'win32' + message += 'Run a new Command Prompt as administrator and try running this command again.' + else + message += 'Try running this command again prefixing it with `sudo`.' + + console.error(message) else if error.message? console.error(error.message)