You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-scp

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-scp - npm Package Compare versions

Comparing version

to
0.0.25

4

lib/index.d.ts

@@ -47,3 +47,5 @@ /// <reference types="node" />

*/
mkdir(remotePath: string, attributes?: InputAttributes): Promise<void>;
mkdir(remotePath: string, attributes?: InputAttributes, options?: {
recursive?: boolean;
}): Promise<void>;
exists(remotePath: string): Promise<string | boolean>;

@@ -50,0 +52,0 @@ /**

@@ -453,18 +453,70 @@ "use strict";

*/
ScpClient.prototype.mkdir = function (remotePath, attributes) {
ScpClient.prototype.mkdir = function (remotePath, attributes, options) {
if (attributes === void 0) { attributes = {}; }
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var parts, currentPath, i, exists, err_1;
var _this = this;
return __generator(this, function (_a) {
utils.haveConnection(this, "mkdir");
return [2 /*return*/, new Promise(function (resolve, reject) {
_this.sftpWrapper.mkdir(remotePath, attributes, function (err) {
if (err) {
reject(err);
}
else {
resolve();
}
});
})];
switch (_a.label) {
case 0:
utils.haveConnection(this, "mkdir");
if (!options.recursive) {
// Simple case: create a single directory
return [2 /*return*/, new Promise(function (resolve, reject) {
_this.sftpWrapper.mkdir(remotePath, attributes, function (err) {
if (err) {
reject(err);
}
else {
resolve();
}
});
})];
}
parts = remotePath.split(this.remotePathSep).filter(function (p) { return p; });
currentPath = remotePath.startsWith(this.remotePathSep) ? this.remotePathSep : '';
i = 0;
_a.label = 1;
case 1:
if (!(i < parts.length)) return [3 /*break*/, 9];
currentPath = currentPath ? utils.joinRemote(this, currentPath, parts[i]) : parts[i];
_a.label = 2;
case 2:
_a.trys.push([2, 7, , 8]);
return [4 /*yield*/, this.exists(currentPath)];
case 3:
exists = _a.sent();
if (!!exists) return [3 /*break*/, 5];
return [4 /*yield*/, new Promise(function (resolve, reject) {
_this.sftpWrapper.mkdir(currentPath, attributes, function (err) {
if (err) {
reject(err);
}
else {
resolve();
}
});
})];
case 4:
_a.sent();
return [3 /*break*/, 6];
case 5:
if (exists !== 'd') {
throw new Error("Cannot create directory '" + remotePath + "': Path exists and is not a directory");
}
_a.label = 6;
case 6: return [3 /*break*/, 8];
case 7:
err_1 = _a.sent();
// Ignore error if directory already exists
if (err_1.code !== 'EEXIST') {
throw err_1;
}
return [3 /*break*/, 8];
case 8:
i++;
return [3 /*break*/, 1];
case 9: return [2 /*return*/];
}
});

@@ -829,2 +881,5 @@ });

});
client.on("close", function () {
client.removeAllListeners();
});
var _loop_1 = function (event_1) {

@@ -837,3 +892,2 @@ client.on(event_1, function () {

}
// @ts-ignore
(_a = options.events)[event_1].apply(_a, args);

@@ -840,0 +894,0 @@ });

@@ -5,3 +5,3 @@ {

"description": "Lightweight, fast and secure SCP function for NodeJS",
"version": "0.0.23",
"version": "0.0.25",
"main": "lib/index.js",

@@ -39,3 +39,3 @@ "types": "lib/index.d.ts",

"dependencies": {
"ssh2": "^1.14.0"
"ssh2": "^1.16.0"
},

@@ -42,0 +42,0 @@ "devDependencies": {

@@ -37,2 +37,3 @@ # New SCP module for NodeJS

* [Set the owner for a path](#sets-the-owner-for-path)
* [Events](#events)
* [Connection options](#Connection-options)

@@ -39,0 +40,0 @@