New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-all-the-things

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-all-the-things - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.jshintrc

91

get-all-the-things.js
let fs = require('fs'),
fileList ='../../get-all-these-things.json';
wget = require('wget-improved'),
mkdirp = require('mkdirp'),
downloaders = [],
//root = '../../', // no need - running `node node_modules/..` is relative
fileList = 'get-all-the-things.json';

@@ -7,3 +11,3 @@ fs.stat(fileList, function(err, stat) {

console.log('You must have the file: ' + fileList);
console.log('Relative to the directory node_modules/get-all-the-things)');
console.log('(relative to this directory)');
return;

@@ -16,8 +20,87 @@ }

// If desired, append the source filetype to the target filename
if (item.retainFiletype == true) {
if (item.retainFiletype === true) {
let fileSplit = item.source.split('.');
item.target += '.' + fileSplit[fileSplit.length - 1];
}
console.log(item);
// Remove any invalid characters, such as > which really fewks things up
// < > : " ' | ? *
item.target = item.target.replace(/<|>|:|"|'|\||\?|\*/g,'');
console.log('\n' + item.source);
console.log('-->\n' + item.target + '\n');
item.targetDir = require('path').dirname(item.target);
if (fs.existsSync(item.targetDir)) {
downloaders.push(Downloader(item.source, item.target));
} else {
console.log("Target folder doesn't exist (creating it)");
mkdirp(item.targetDir, function (err) {
if (err) {
console.log("Couldn't create target path:");
console.error(err);
}
else {
downloaders.push(Downloader(item.source, item.target));
}
});
}
return;
});
// Start all downloads
downloaders.map(downloader => {
downloader.downloadFile();
});
// Check our progress while any downloads are still going
let progressCheck = setInterval(function() {
var allDone = true;
downloaders.map(downloader => {
if (downloader.getProgress() != 100) {
allDone = false;
console.log(downloader.getProgress() + '% of ' + downloader.getFileSize() + ' for ' + downloader.getTarget());
}
});
if (allDone) {
clearInterval(progressCheck);
console.log('Done!\n');
} else {
console.log('');
}
}, 100);
});
Downloader = (source, target) => {
let download,
fileSize = 0,
progress = 0;
return {
downloadFile: () => {
download = wget.download(source, target);
download.on('error', function(err) {
console.log(err);
});
download.on('start', function(_fileSize) {
fileSize = _fileSize;
//console.log('Starting download of: ' + Math.round(fileSize / 2014 * 10) / 10 + 'kb');
});
download.on('end', function(output) {
//console.log(output);
});
download.on('progress', function(_progress) {
progress = Math.round(_progress * 100);
});
},
getProgress: () => {
return progress;
},
getTarget: () => {
return target;
},
getFileSize: () => {
return Math.round(fileSize / 2014 * 10) / 10 + 'kb';
}
};
};

8

package.json
{
"name": "get-all-the-things",
"version": "1.0.1",
"version": "1.0.2",
"description": "Download listed files from a json array",

@@ -23,3 +23,7 @@ "main": "get-all-the-things.js",

},
"homepage": "https://github.com/entozoon/get-all-the-things#readme"
"homepage": "https://github.com/entozoon/get-all-the-things#readme",
"dependencies": {
"mkdirp": "0.5.1",
"wget-improved": "1.4.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