@cyberalien/deploy-utils 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ssh/upload-files.js +9 -11
- package/package.json +1 -1
package/lib/ssh/upload-files.js
CHANGED
|
@@ -73,29 +73,27 @@ async function processQueue(client, queue, callback) {
|
|
|
73
73
|
* For binary files use putSFTPFiles() instead
|
|
74
74
|
*/
|
|
75
75
|
async function uploadSFTPFiles(client, remoteRootDir, files) {
|
|
76
|
+
let index = 0;
|
|
76
77
|
const filenames = [];
|
|
77
78
|
let filesCount = 0;
|
|
78
79
|
for (const file in files) {
|
|
79
80
|
filesCount++;
|
|
80
|
-
if (files[file] === null)
|
|
81
|
+
if (files[file] === null) {
|
|
82
|
+
console.log(`[${index} / ${filesCount}] Deleting ${file}`);
|
|
83
|
+
await execSFTPCommand(client, `rm -f "${join(remoteRootDir, file)}"`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
81
86
|
filenames.push(file);
|
|
82
87
|
}
|
|
88
|
+
if (!filenames.length) return;
|
|
83
89
|
await createDirectories(client, remoteRootDir, filenames);
|
|
84
|
-
|
|
85
|
-
let index = 0;
|
|
86
|
-
for (const file in files) {
|
|
90
|
+
await processQueue(client, filenames, async (sftp, file) => {
|
|
87
91
|
index++;
|
|
88
92
|
const content = files[file];
|
|
89
93
|
const target = join(remoteRootDir, file);
|
|
90
|
-
if (content === null) {
|
|
91
|
-
console.log(`[${index} / ${filesCount}] Deleting ${file}`);
|
|
92
|
-
await execSFTPCommand(client, `rm -f "${target}"`);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
94
|
console.log(`[${index} / ${filesCount}] Uploading ${file}`);
|
|
96
95
|
await uploadSFTPFile(sftp, target, typeof content === "string" ? content : JSON.stringify(content, null, 2) + "\n");
|
|
97
|
-
}
|
|
98
|
-
sftp.end();
|
|
96
|
+
});
|
|
99
97
|
}
|
|
100
98
|
/**
|
|
101
99
|
* Upload multiple local files
|
package/package.json
CHANGED