From d53a1669766a1a77bda34ee52109bee9c8735bda Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 30 Nov 2015 15:59:23 +0100 Subject: Do not include hidden folders by default --- cli/actions.js | 9 ++++++--- cli/surfer.js | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/actions.js b/cli/actions.js index 954ca6b..25643da 100644 --- a/cli/actions.js +++ b/cli/actions.js @@ -31,17 +31,20 @@ function checkConfig() { console.error('Using server %s', config.server().yellow); } -function collectFiles(filesOrFolders) { +function collectFiles(filesOrFolders, options) { var tmp = []; filesOrFolders.forEach(function (filePath) { + var baseName = path.basename(filePath); + if (!options.all && baseName[0] === '.' && baseName.length > 1) return; + var stat = fs.statSync(filePath); if (stat.isFile()) { tmp.push(filePath); } else if (stat.isDirectory()) { 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 { console.log('Skipping %s', filePath.cyan); } @@ -90,7 +93,7 @@ function login(uri) { function put(filePath, otherFilePaths, options) { checkConfig(); - var files = collectFiles([ filePath ].concat(otherFilePaths)); + var files = collectFiles([ filePath ].concat(otherFilePaths), options); async.eachSeries(files, function (file, callback) { var relativeFilePath; diff --git a/cli/surfer.js b/cli/surfer.js index ad37917..8920641 100755 --- a/cli/surfer.js +++ b/cli/surfer.js @@ -16,6 +16,7 @@ program.command('login ') program.command('put [files...]') .option('-d --destination ', 'Destination folder. This is prepended to the relative path') + .option('-a --all', 'Also include hidden files and folders.', false) .description('Put a file') .action(actions.put); -- cgit v1.2.3