Commit d53a1669 by Johannes Zellner

Do not include hidden folders by default

1 parent de9b8cee
Showing with 7 additions and 3 deletions
...@@ -31,17 +31,20 @@ function checkConfig() { ...@@ -31,17 +31,20 @@ function checkConfig() {
console.error('Using server %s', config.server().yellow); console.error('Using server %s', config.server().yellow);
} }
function collectFiles(filesOrFolders) { function collectFiles(filesOrFolders, options) {
var tmp = []; var tmp = [];
filesOrFolders.forEach(function (filePath) { filesOrFolders.forEach(function (filePath) {
var baseName = path.basename(filePath);
if (!options.all && baseName[0] === '.' && baseName.length > 1) return;
var stat = fs.statSync(filePath); var stat = fs.statSync(filePath);
if (stat.isFile()) { if (stat.isFile()) {
tmp.push(filePath); tmp.push(filePath);
} else if (stat.isDirectory()) { } else if (stat.isDirectory()) {
var files = fs.readdirSync(filePath).map(function (file) { return path.join(filePath, file); }); var files = fs.readdirSync(filePath).map(function (file) { return path.join(filePath, file); });
tmp = tmp.concat(collectFiles(files)); tmp = tmp.concat(collectFiles(files, options));
} else { } else {
console.log('Skipping %s', filePath.cyan); console.log('Skipping %s', filePath.cyan);
} }
...@@ -90,7 +93,7 @@ function login(uri) { ...@@ -90,7 +93,7 @@ function login(uri) {
function put(filePath, otherFilePaths, options) { function put(filePath, otherFilePaths, options) {
checkConfig(); checkConfig();
var files = collectFiles([ filePath ].concat(otherFilePaths)); var files = collectFiles([ filePath ].concat(otherFilePaths), options);
async.eachSeries(files, function (file, callback) { async.eachSeries(files, function (file, callback) {
var relativeFilePath; var relativeFilePath;
......
...@@ -16,6 +16,7 @@ program.command('login <url>') ...@@ -16,6 +16,7 @@ program.command('login <url>')
program.command('put <file> [files...]') program.command('put <file> [files...]')
.option('-d --destination <folder>', 'Destination folder. This is prepended to the relative <file> path') .option('-d --destination <folder>', 'Destination folder. This is prepended to the relative <file> path')
.option('-a --all', 'Also include hidden files and folders.', false)
.description('Put a file') .description('Put a file')
.action(actions.put); .action(actions.put);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!