]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/commitdiff
Do not include hidden folders by default
authorJohannes Zellner <johannes@nebulon.de>
Mon, 30 Nov 2015 14:59:23 +0000 (15:59 +0100)
committerJohannes Zellner <johannes@nebulon.de>
Mon, 30 Nov 2015 14:59:23 +0000 (15:59 +0100)
cli/actions.js
cli/surfer.js

index 954ca6b36e27a7556dda9ed18ac6ea031402694f..25643da705a0070153af8ec6bff6f3f44f88a432 100644 (file)
@@ -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;
index ad37917d3eb74793c3be1016a63e6aece89cdf30..8920641896cafd986fb0e1880ee72e50154f091e 100755 (executable)
@@ -16,6 +16,7 @@ program.command('login <url>')
 
 program.command('put <file> [files...]')
     .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')
     .action(actions.put);