Socket
Socket
Sign inDemoInstall

amass

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

amass - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

46

bin/amass.js

@@ -12,3 +12,2 @@ #!/usr/bin/env node

var fs = require('fs');
var path = require('path');

@@ -18,3 +17,2 @@

var getopt = require('posix-getopt');
var plugins = require('../plugins');

@@ -34,4 +32,4 @@ var package = require('../package.json');

'',
'plugins are installed to `' + plugins.dir + '\' and as such, may',
'require root or super-user privileges',
'plugins are installed to `/var/amass/node_modules` and as such, may',
'require root or super-user privileges to modify',
'',

@@ -42,2 +40,3 @@ '-a, --add <name> add the plugin <name> to amass',

'-r, --remove <name> remove the plugin <name> from amass',
'-t, --test <module> test a module, takes a directory or js file',
'-u, --updates check for available updates',

@@ -54,2 +53,3 @@ '-v, --version print the version number and exit'

'r(remove)',
't:(test)',
'u(updates)',

@@ -62,2 +62,3 @@ 'v(version)'

var remove = false;
var test;
var option;

@@ -70,2 +71,3 @@ while ((option = parser.getopt()) !== undefined) {

case 'r': remove = true; break;
case 't': test = option.optarg; break;
case 'u': // check for updates

@@ -83,24 +85,26 @@ require('latest').checkupdate(package, function(ret, msg) {

// handle add, remove, or list
function cb(err, out, code) {
if (out) process.stdout.write(out);
if (err) process.stderr.write(err);
process.exit(code);
if (add || list || remove) {
var plugins = require('../plugins');
// handle add, remove, or list
function cb(err, out, code) {
if (out) process.stdout.write(out);
if (err) process.stderr.write(err);
process.exit(code);
}
if (add) return plugins.add(args, cb);
if (list) return plugins.list(cb);
if (remove) return plugins.remove(args, cb);
}
if (add) return plugins.add(args, cb);
if (list) return plugins.list(cb);
if (remove) return plugins.remove(args, cb);
// try to load the plugins
var pluginsavail;
try {
var pluginnames = fs.readdirSync(plugins.dir);
pluginsavail = pluginnames.map(function(name) {
// return the full path
return path.join(plugins.dir, name);
console.dir(test);
if (test) {
require(path.resolve(test))(function(err, data) {
if (err) throw err;
console.log(JSON.stringify(data, null, 2));
});
} catch (e) {}
return;
}
// amass!
amass(pluginsavail, function(errors, data) {
amass(function(errors, data) {
if (errors) errors.forEach(function(err) {

@@ -107,0 +111,0 @@ console.error(err);

@@ -14,2 +14,3 @@ /**

var package = require('./package.json');
var plugins = require('./plugins').plugins;
var modules = {

@@ -22,8 +23,3 @@ os: require('./lib/os'),

function amass(plugins, cb) {
if (typeof plugins === 'function') {
cb = plugins;
plugins = null;
}
function amass(cb) {
var data = {};

@@ -33,11 +29,9 @@ var errors = [];

version: package.version,
plugins: plugins || []
plugins: plugins
};
// try to load the plugins
if (plugins) {
plugins.forEach(function(plugin) {
modules[path.basename(plugin).replace(/^amass-/, '')] = require(plugin);
});
}
plugins.forEach(function(plugin) {
modules[path.basename(plugin).replace(/^amass-/, '')] = require(plugin);
});
var keys = Object.keys(modules);

@@ -44,0 +38,0 @@ var len = keys.length;

@@ -5,3 +5,3 @@ {

"author": "Dave Eddy <dave@daveeddy.com> (http://www.daveeddy.com)",
"version": "0.0.6",
"version": "0.0.7",
"bin": {

@@ -8,0 +8,0 @@ "amass": "./bin/amass.js"

@@ -12,25 +12,41 @@ var fs = require('fs');

module.exports.basedir = dir;
var commands = {
add: ['npm', 'install', '-S'],
list: ['npm', 'ls', '--depth', '0'],
remove: ['npm', 'remove', '-S']
};
// try to load the plugins
var plugins = [];
try {
var pluginnames = fs.readdirSync(dir);
plugins = pluginnames.map(function(name) {
// return the full path
return path.join(dir, name);
});
} catch (e) {}
// exports
module.exports.plugins = plugins;
module.exports.dir = dir;
module.exports.add = _npm_do('add');
module.exports.list = _npm_do('list');
module.exports.remove = _npm_do('remove');
module.exports.add = add;
module.exports.list = list;
module.exports.remove = remove;
function add(args, cb) {
_check_exists();
var command = ['npm', 'install', '-S'].concat(args);
exec(command, {cwd: basedir}, cb);
// the entry point, return a function to call
function _npm_do(action) {
return function(args, cb) {
if (typeof args === 'function') {
cb = args;
args = null;
}
_check_exists();
var cmd = commands[action];
if (args) cmd = cmd.concat(args);
exec(cmd, {cwd: basedir}, cb);
};
}
function list(cb) {
_check_exists();
var command = ['npm', 'ls', '--depth', '0']
exec(command, {cwd: basedir}, cb);
}
function remove(args, cb) {
_check_exists();
var command = ['npm', 'remove', '-S'].concat(args);
exec(command, {cwd: basedir}, cb);
}
// check for, and create, the necessary directories/files
// for plugins
function _check_exists() {

@@ -44,2 +60,3 @@ if (!fs.existsSync(p)) {

version: package.version,
private: true,
name: package.name

@@ -46,0 +63,0 @@ };

@@ -82,5 +82,3 @@ amass

amass@0.0.4 /private/var/amass
└─┬ amass-etc-passwd@0.0.0
└─┬ etc-passwd@0.1.1
└── lazylines@1.0.0
└── amass-etc-passwd@0.0.0

@@ -135,2 +133,8 @@ That shows you the installed plugins and their dependencies. If the output

### testing
You can test a module you are writing using `amass -t`
amass -t <jsfile or module dir>
### technical details

@@ -137,0 +141,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