From: Girish Ramakrishnan Date: Sat, 28 Nov 2015 00:08:08 +0000 (-0800) Subject: fix path resolution X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=sidebyside;h=1c20715d8249ae081aae56f27e12e225282e9e38;hp=755569a3d7aad123db0854e282b731d80c3f9ca2;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git fix path resolution --- diff --git a/cli/actions.js b/cli/actions.js index 6fb9893..735b631 100644 --- a/cli/actions.js +++ b/cli/actions.js @@ -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);