Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FvckSh1t committed Dec 13, 2013
1 parent 2678132 commit c35e045
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/sd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

require('../')(process.argv, function() {
process.exit();
});
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function su(argv) {
var cmds = argv.slice(2);

console.log(cmds);
}
25 changes: 25 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var exec = require('child_process').exec;

module.exports = function s(argv, done) {
var cmds = argv.slice(2),
sudo = exec('sudo ' + argv.join(' '));

sudo.on('error', function(err) {
if (done) done(err);
});
sudo.on('exit', function() {
if (done) done(null);
});
sudo.on('close', function() {
if (done) done(null);
});

process.stdin.pipe(sudo.stdin);
sudo.stdout.pipe(process.stdout);

//sudo.stderr.pipe(process.stderr);
sudo.stderr.on('data', function(chunk) {
if (chunk.toString() == 'Sorry, try again.\n') return;
process.stdout.write(chunk);
});
}
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "sd",
"version": "0.0.1",
"bin": {
"s": "./bin/sd",
"sd": "./bin/sd"
},
"main": "./lib/",
"description": "A CLI tool for convinence of `sudo` on Linux",
"repository": {
"type": "git",
"url": "https://github.com/Fritz-Lium/s"
},
"keywords": [
"linux",
"cmd",
"sudo",
"sd",
"s"
],
"author": "Fritz-Lium <[email protected]> (https://github.com/Fritz-Lium)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Fritz-Lium/s/issues"
},
"homepage": "https://github.com/Fritz-Lium/s"
}
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var sd = require('../lib');

sd(process.argv.slice(2), function() {
process.exit();
});

0 comments on commit c35e045

Please sign in to comment.