Comparing version 0.1.2 to 0.1.3
@@ -9,19 +9,18 @@ #!/usr/bin/env node | ||
var path = require("path"); | ||
var fs = require("fs"); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var prototypes = require('./prototypes'); | ||
var args = process.argv; | ||
console.log('Arg: %s', args[0], args[1]); | ||
var args = process.argv.slice(1); | ||
/* | ||
var arg, base; | ||
do arg = args.shift(); | ||
while ( fs.realpathSync(arg) !== __filename | ||
&& (base = path.basename(arg)) !== "node-supervisor" | ||
&& base !== "supervisor" | ||
&& base !== "supervisor.js" | ||
) | ||
var arg = args.shift(); | ||
var realpath = fs.realpathSync(arg); | ||
var name = path.basename(arg).substringUpTo('.'); | ||
var lib = require('./' + name + '.js'); | ||
if (!lib) | ||
{ | ||
console.error('Could not find %s', name); | ||
return; | ||
} | ||
lib.run(args); | ||
require("./supervisor").run(args) | ||
*/ | ||
@@ -336,5 +336,5 @@ 'use strict'; | ||
*/ | ||
function help(args) | ||
function help() | ||
{ | ||
console.log('Usage: %s %s [options] URL', args[0], args[1]); | ||
console.log('Usage: loadtest [options] URL'); | ||
console.log(' where URL can be a regular HTTP or websocket URL.'); | ||
@@ -351,4 +351,2 @@ console.log('Options are:'); | ||
var numbersParsed = 0; | ||
/** | ||
@@ -395,7 +393,6 @@ * Parse one argument and change options accordingly. | ||
/** | ||
* Process command line arguments. | ||
* Process command line arguments and run | ||
*/ | ||
function processArgs(originalArgs) | ||
exports.run = function(args) | ||
{ | ||
var args = originalArgs.slice(2); | ||
var options = DEFAULT_OPTIONS; | ||
@@ -415,3 +412,3 @@ while (parseArgument(args, options)) | ||
} | ||
return help(originalArgs); | ||
return help(); | ||
} | ||
@@ -425,4 +422,4 @@ options.url = args[0]; | ||
{ | ||
processArgs(process.argv); | ||
exports.run(process.argv.slice(2)); | ||
} | ||
@@ -32,2 +32,49 @@ 'use strict'; | ||
/** | ||
* Return the piece of string until the argument is found. | ||
* 'hi.there'.substringUpTo('.') => 'hi' | ||
*/ | ||
String.prototype.substringUpTo = function(str) | ||
{ | ||
if (!this.contains(str)) | ||
{ | ||
return this; | ||
} | ||
return this.slice(0, this.indexOf(str)); | ||
} | ||
/** | ||
* Return the piece of string up until the last occurrence of the argument. | ||
* 'hi.there.you'.substringUpToLast('.') => 'hi.there' | ||
*/ | ||
String.prototype.substringUpToLast = function(str) | ||
{ | ||
if (!this.contains(str)) | ||
{ | ||
return this; | ||
} | ||
return this.slice(0, this.lastIndexOf(str)); | ||
} | ||
/** | ||
* Return the piece of string starting with the argument; empty string if not found. | ||
* 'hi.there'.substringFrom('.') => 'there' | ||
*/ | ||
String.prototype.substringFrom = function(str) | ||
{ | ||
if (!this.contains(str)) | ||
{ | ||
return ''; | ||
} | ||
return this.slice(this.indexOf(str) + str.length); | ||
} | ||
/** | ||
* Find out if the string contains the argument at any position. | ||
*/ | ||
String.prototype.contains = function(str) | ||
{ | ||
return this.indexOf(str) != -1; | ||
}; | ||
/** | ||
* Replace all occurrences of a string the replacement. | ||
@@ -49,2 +96,4 @@ */ | ||
testing.assert(!'pepito'.startsWith('po'), 'Invalid match using endsWith()', callback); | ||
testing.assertEquals('hi.there.you'.substringUpTo('.'), 'hi', 'String.substringUpTo() not working!', callback); | ||
testing.assertEquals('hi.there.you'.substringUpToLast('.'), 'hi.there', 'String.substringUpToLast() not working!', callback); | ||
testing.assertEquals('pepito'.replaceAll('p', 'c'), 'cecito', 'Invalid replaceAll().', callback); | ||
@@ -51,0 +100,0 @@ testing.success(callback); |
@@ -89,3 +89,3 @@ 'use strict'; | ||
{ | ||
console.log('Usage: %s %s [port]'); | ||
console.log('Usage: testserver [port]'); | ||
console.log(' starts a test server on the given port, default 80.'); | ||
@@ -97,3 +97,3 @@ } | ||
*/ | ||
function processArgs(args) | ||
exports.run = function(args) | ||
{ | ||
@@ -120,4 +120,4 @@ while (args.length > 0) | ||
{ | ||
processArgs(process.argv.slice(2)); | ||
exports.run(process.argv.slice(2)); | ||
} | ||
{ | ||
"name": "loadtest", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Load test scripts.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://milliearth.org/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
28845
1045
2