- async.eachSeries(files, function (file, callback) {
- var relativeFilePath;
-
- if (path.isAbsolute(file)) {
- relativeFilePath = path.basename(file);
- } else if (path.resolve(file).indexOf(process.cwd()) === 0) { // relative to current dir
- relativeFilePath = path.resolve(file).slice(process.cwd().length + 1);
- } else { // relative but somewhere else
- relativeFilePath = path.basename(file);
- }
+function putOne(filePath, destination, options, callback) {
+ const absoluteFilePath = path.resolve(filePath);
+ const stat = safe.fs.statSync(absoluteFilePath);
+ if (!stat) return callback(`Could not stat ${filePath}: ${safe.error.message}`);
+
+ let files, base;
+
+ if (stat.isFile()) {
+ base = destination + path.basename(filePath);
+ files = [ absoluteFilePath ];
+ } else if (stat.isDirectory()) {
+ base = destination + (filePath.endsWith('.') ? '' : path.basename(filePath) + '/');
+ files = collectFiles([ absoluteFilePath ], options);
+ } else {
+ return callback(); // ignore
+ }