Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

faster-webpack-upload-plugin

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faster-webpack-upload-plugin - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "faster-webpack-upload-plugin",
"version": "1.0.1",
"version": "1.0.2",
"author": "WangTieZhu92",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -41,66 +41,67 @@ 'use strict'

upload = async (compilation) => {
const {localPath, remotePath, log, clearFolder, ...others} = this.options;
const folders = [];
const files = [];
const uploadedFiles = [];
upload(options) {
return async function (compilation) {
const {localPath, remotePath, log, clearFolder, ...others} = options;
const folders = [];
const files = [];
const uploadedFiles = [];
const sftp = new Client();
await sftp.connect({...others});
const sftp = new Client();
await sftp.connect({...others});
if (this.firstEmit) {
try {
await sftp.exists(remotePath);
if (clearFolder) {
log && console.log(chalk.red('clearing remote folder...'));
await sftp.rmdir(remotePath, true);
if (this.firstEmit) {
try {
await sftp.exists(remotePath);
if (clearFolder) {
log && console.log(chalk.red('clearing remote folder...'));
await sftp.rmdir(remotePath, true);
await sftp.mkdir(remotePath, true);
}
} catch (e) {
await sftp.mkdir(remotePath, true);
}
} catch (e) {
await sftp.mkdir(remotePath, true);
}
getFolderNFiles(folders, files, localPath, remotePath);
getFolderNFiles(folders, files, localPath, remotePath);
this.firstEmit = false;
} else {
const assets = compilation.assets;
for (const file in assets) {
if (assets[file].emitted) {
files.push({
local: assets[file].existsAt,
remote: formatRemotePath(remotePath, file),
size: assets[file].size(),
})
this.firstEmit = false;
} else {
const assets = compilation.assets;
for (const file in assets) {
if (assets[file].emitted) {
files.push({
local: assets[file].existsAt,
remote: formatRemotePath(remotePath, file),
size: assets[file].size(),
})
}
}
}
}
if (folders.length > 0) {
log && console.log(chalk.green('creating remote folders...'));
await Promise.all(folders.map(folder => sftp.mkdir(folder).catch(() => log && console.log(chalk.yellow('folder create failed,it might exists')))));
}
if (folders.length > 0) {
log && console.log(chalk.green('creating remote folders...'));
await Promise.all(folders.map(folder => sftp.mkdir(folder).catch(() => log && console.log(chalk.yellow('folder create failed,it might exists')))));
}
const pb = new ProgressBar('', 50);
const pb = new ProgressBar('', 50);
if (files.length > 0) {
await Promise.all(files.map(file =>
sftp.fastPut(file.local, file.remote)
.catch(log && console.log)
.then(result => {
if (result) {
uploadedFiles.push(file);
pb.render({
percent: (uploadedFiles.length / files.length).toFixed(4),
completed: uploadedFiles.length,
total: files.length,
})
}
})));
if (files.length > 0) {
await Promise.all(files.map(file =>
sftp.fastPut(file.local, file.remote)
.catch(log && console.log)
.then(result => {
if (result) {
uploadedFiles.push(file);
pb.render({
percent: (uploadedFiles.length / files.length).toFixed(4),
completed: uploadedFiles.length,
total: files.length,
})
}
})));
log && console.log('\n' + chalk.green('upload done! files size: ' + (uploadedFiles.reduce((pre, next) => ({size: pre.size + next.size}), {size: 0}).size / 1000).toFixed(2) + ' KB'));
log && console.log('\n' + chalk.green('upload done! files size: ' + (uploadedFiles.reduce((pre, next) => ({size: pre.size + next.size}), {size: 0}).size / 1000).toFixed(2) + ' KB'));
}
}
}

@@ -107,0 +108,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc