Skip to content

Instantly share code, notes, and snippets.

@watilde
Created May 3, 2013 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watilde/5512816 to your computer and use it in GitHub Desktop.
Save watilde/5512816 to your computer and use it in GitHub Desktop.
Get the name of Dotfiles;
(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