]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/commitdiff
fix path resolution
authorGirish Ramakrishnan <girish@forwardbias.in>
Sat, 28 Nov 2015 00:08:08 +0000 (16:08 -0800)
committerGirish Ramakrishnan <girish@forwardbias.in>
Sat, 28 Nov 2015 00:08:08 +0000 (16:08 -0800)
cli/actions.js

index 6fb98937e73a57f8e26fd5400dfdc092fce04799..735b631600092ef4054895bd1577d9ffca22cb97 100644 (file)
@@ -93,7 +93,15 @@ function put(filePath, otherFilePaths, options) {
     var files = collectFiles([ filePath ].concat(otherFilePaths));
 
     async.eachSeries(files, function (file, callback) {
-        var relativeFilePath = path.resolve(file).slice(process.cwd().length + 1);
+        var relativeFilePath;
+        if (path.isAbsolute(file)) {
+            relativeFilePath = path.basename(file);
+        } else if (path.resolve(file).indexOf(process.cwd().length) === 0) { // relative to current dir
+            relativeFilePath = path.resolve(file).slice(process.cwd().length + 1);
+        } else { // relative but somewhere else
+            relativeFilePath = path.basename(file);
+        }
+
         var destinationPath = (options.destination ? '/' + options.destination : '') + '/' + relativeFilePath;
         console.log('Uploading file %s -> %s', relativeFilePath.cyan, destinationPath.cyan);