Fix setName
This commit is contained in:
parent
181630a154
commit
36b303799e
1 changed files with 4 additions and 4 deletions
8
index.js
8
index.js
|
@ -14,14 +14,14 @@ function validName(string) {
|
|||
return /^[a-z0-9 ]+$/i.test(string) && string.trim().length > 0;
|
||||
}
|
||||
|
||||
var Name = undefined;
|
||||
|
||||
var Sudo = function(command, end) {
|
||||
if (Node.process.platform === 'darwin') return Sudo.Mac(command, end);
|
||||
end('Platform not yet supported.');
|
||||
// TO DO: Add support for linux.
|
||||
};
|
||||
|
||||
Sudo.name = undefined;
|
||||
|
||||
Sudo.Mac = function(command, end, count) {
|
||||
if (count === undefined) count = 0;
|
||||
if (count >= 2) return end(new Error('Permission denied after several password prompts.'));
|
||||
|
@ -47,7 +47,7 @@ Sudo.Mac = function(command, end, count) {
|
|||
|
||||
Sudo.Mac.prompt = function(end) {
|
||||
var self = this;
|
||||
var title = Sudo.name || Node.process.title;
|
||||
var title = Name || Node.process.title;
|
||||
if (!validName(title)) return end(new Error('Please use sudo.setName(string) to set your app name (process.title contains invalid characters).'));
|
||||
var temp = Node.os.tmpdir();
|
||||
if (!temp) return end(new Error('Requires os.tmpdir() to be defined.'));
|
||||
|
@ -120,5 +120,5 @@ exports.touch = function(end) {
|
|||
|
||||
exports.setName = function(string) {
|
||||
if (!validName(string)) throw new Error('Name must be alphanumeric only (spaces are allowed).');
|
||||
Sudo.name = string;
|
||||
Name = string;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue