spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
385 stars 96 forks source link

Get filename using path.basename #41

Open martinvl opened 8 years ago

martinvl commented 8 years ago

When globbing for files (e.g. "foo.*") only the first file gets a correct fname. The other files get .. prepended to their fname, which causes them to be put in the wrong remote location.

Fixes #27

lepture commented 8 years ago

Imaging this:

  1. relative path: /foo
  2. file: /foo/bar/baz.txt

Using path.basename you will get baz.txt, but bar/baz.txt is expected.

martinvl commented 8 years ago

That is true.

Check whether files[0] is a directory using fs.stat and use path.dirname if it isn't then?