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

n-get

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n-get - npm Package Compare versions

Comparing version 0.0.24 to 0.0.25

docs/argv.html

50

index.js

@@ -5,7 +5,10 @@ #! /usr/bin/env node

var path = require("path")
,fs = require("fs")
, argv = require("minimist")(process.argv)
, chdir = require("./lib/chdir")
, uriManager = require("./lib/uriManager")
, Crawler = require("simplecrawler");
//argv
, chdir = require("./lib/chdir")
, Crawler = require("simplecrawler"); //TODO this is only alpha
var destination

@@ -19,21 +22,32 @@ , argvs

// print process.argv TODO make this a module in utils
//@Description: Take argv from cli.
process.argv.forEach(function(val, index, array) {
//grab next index value for destination to write
if (val === "-d") {
array.slice(index, index+1);
return destination = array[index+1];
}
if ( index > 1 && index !== array.indexOf(destination + 1) && index !== array.indexOf(destination)){
reqUrls.push(val);
}
});
if (val === "-d") {
array.slice(index, index+1);
return destination = array[index+1];
}
if ( index > 1 && index !== array.indexOf(destination + 1) && index !== array.indexOf(destination)){
reqUrls.push(val);
}
})
//process urls
console.log(reqUrls);
//process urls
//@Description:
//Confirm that destination of the -d flag is a real path.
//The calles the chdir module.
if(typeof destination !== 'undefined') {
fs.realpath(destination, function (err, resolvedPath) {
if (err) throw err;
destination = chdir(resolvedPath);
return destination
});
}
// -------------------------------Process urls
//@Description check the url and make if work for the pipe. Let users be idiots and type loose.
var sendDownPipe = reqUrls.map(uriManager);
//@Description take all the paths and download them in an async crazy manner for now. Maybe we will add a napkin in l8er for the squares that require them. ;)
var recersivePipe = require("./lib/recersivePipe")
recersivePipe(sendDownPipe)
console.log("this is destination", destination);
recersivePipe(sendDownPipe, destination)
//below this ----------------------------- to modules
/*
Description: This module acts like a 'chdir'
Param: {String} should be me the destination folder
*/
module.exports = function chdir(dir) {

@@ -4,0 +9,0 @@ try {

@@ -12,5 +12,7 @@ var request = require("request")

// Keep tracks of the files to download.
var fileCounter = 1;
var fileCounter = 1;
//get destination for streams
//@description: get destination for streams.
//TODO move this into a different module. Doesnt' belong here.
function getDestination(destination) {

@@ -26,2 +28,3 @@ if(!destination || destination === null || destination === "./" || destination === " "){

//@Description: Handles file size to display
function bytesToSize(bytes) {

@@ -35,5 +38,9 @@ var k = 1000;

// Takes array of urls and pipes them disk
//@Description: Takes array of urls and pipes them disk.
//@para urls {array.object.instance}
//@destination {String} is this a verified location on disk
var time, diff, stateDisplay, fileSize;
function recersivePipe(urls, distination){
function recersivePipe(urls, destination){
if(urls === 'undefined') console.log("FAILED To Process URI");
//start timer

@@ -44,6 +51,6 @@ time = process.hrtime();

var writePath = process.cwd().toString();
var popped = urls.pop().toString();
poppedReg = path.basename(popped); //TODO rename this var
var popped = urls.pop();
poppedReg = path.basename(popped).toString(); //TODO rename this var
//get the specific destination if user enters
if(!typeof destination === "undefined") {
if(typeof destination !== "undefined") {
writePath = getDestination(destination) + "/" + poppedReg;

@@ -59,3 +66,3 @@ }else {

} catch (err) {
//name doesn't exist
//name doesn't exist.... proceeed
}

@@ -67,4 +74,6 @@ var r = progress(request(popped))

.on("progress", function (state) {
fileSize = state.total;
console.log(state.percent + "%");
if(state.total !== null) {
fileSize = state.total;
console.log(state.percent + "%");
}
})

@@ -71,0 +80,0 @@ .on("end", function(){

{
"name": "n-get",
"version": "0.0.24",
"version": "0.0.25",
"homepage": "https://github.com/bingeboy/n-get",

@@ -5,0 +5,0 @@ "description": "pipe request to disk",

@@ -38,3 +38,3 @@ #n-get

```
<!--(
### Adavanced Mode

@@ -46,4 +46,4 @@ All of the above and spider crawling abilites

```
)-->
* If no protocal is used in the file path http will be used by default

@@ -50,0 +50,0 @@ * If no writePath is provided current location will be used by default

@@ -7,6 +7,16 @@

describe("get write stream with -d flag", function(){
it("process.argv after -d flag", function(){
var urls = ["google.com", "-d", "temp"]
expect(destination).to.have.a.property("temp");
describe("get write stream with -d flag", function( ) {
it("process.argv after -d flag", function( ) {
var urls = ["google.com", "-d", "temp"];
urls.forEach(function(val, index, array) {
if (val === "-d") {
array.slice(index, index+1);
return destination = array[index+1];
}
if ( index > 1 && index !== array.indexOf(destination + 1) && index !== array.indexOf(destination)){
reqUrls.push(val);
}
})
expect(destination).equal("temp");
});

@@ -13,0 +23,0 @@ });

var expect = require("chai").expect;
var uriManager = require("../lib/uriManager.js");
describe("uriManage takes array or uri and verifies them and returns", function(){
describe("uriManage takes array or uri and verifies them and returns", function( ) {
describe("#requestUri()", function(){
it("It Should add a protocal if of http:// if one isn't declared", function(){
var urls = ["google.com", "http://google.com", "192.168.1.1", "http://192.168.1.1", "https://github.com/bingeboy", "ftp://192.168.1.1"];
describe("#requestUri()", function() {
it("It Should add a protocal if of http:// if one isn't declared", function( ) {
var urls = ["google.com",
"http://google.com",
"192.168.1.1",
"http://192.168.1.1",
"https://github.com/bingeboy",
"ftp://192.168.1.1"
];
var results = urls.map(uriManager);
console.log(results);
//expect(results).to.have.a.property("http://google.com");
expect(results[0]).equal("http://google.com/");
expect(results[1]).equal("http://google.com/");
expect(results[2]).equal("http://192.168.1.1/");
expect(results[3]).equal("http://192.168.1.1/");
expect(results[4]).equal("https://github.com/bingeboy");
expect(results[5]).equal("ftp://192.168.1.1/");
});
});
});
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