Created
May 3, 2013 18:57
-
-
Save watilde/5512816 to your computer and use it in GitHub Desktop.
Get the name of Dotfiles;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
var spawn, dotfiles; | |
spawn = require('child_process').spawn; | |
dotfiles = function() { | |
var ls, grep; | |
ls = spawn('ls', ['-A']); | |
grep = spawn('grep', ['^\\.']); | |
ls.stdout.on('data', function (data) { | |
grep.stdin.write(data); | |
}); | |
ls.stderr.on('data', function (data) { | |
throw ('ls stderr: ' + data); | |
}); | |
ls.on('close', function (code) { | |
if (code !== 0) { | |
throw ('ls process exited with code ' + code); | |
} | |
grep.stdin.end(); | |
}); | |
grep.stdout.on('data', function (data) { | |
throw ('' + data); | |
}); | |
grep.stderr.on('data', function (data) { | |
throw ('grep stderr: ' + data); | |
}); | |
grep.on('close', function (code) { | |
if (code !== 0) { | |
throw ('grep process exited with code ' + code); | |
} | |
}); | |
}; | |
dotfiles(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment