Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.invoke = function(cmd, args, opts, done) {
var working = CORE.cwd(),
force = false;
opts.on('working', function(k,v) { working = v; });
opts.on('force', function() { force = true; });
opts.on('no-force', function() { force= false; });
var packageIds = opts.parse(args);
if (packageIds.length===0) {
return done(new Error("Package name required"));
}
// first we need to find the working package to install in
(function(done) {
working = CORE.path.normalize(working);
CORE.async(function() {
Cmds.invoke = function(cmd, args, done) {
if (arguments.length<2) {
throw new Error("invoke() requires least cmd and callback");
}
if (!cmd) cmd = 'help';
// Find nearest package and automatically register it so you can work inside
// of a project
var pkg = require.loader.openNearestPackage(CORE.cwd());
if (pkg) require.loader.register(pkg.path);
Cmds.commands(function(err, commands) {
if (err) return done(err);
var packageId = commands[cmd.toLowerCase()], exports;
if (packageId) {
try {
exports = require(packageId);
} catch(e) {
exports = null;
}
}
var opts = new optparse.OptionParser(STD_SWITCHES);
if (!exports || !exports.invoke) {
exports.invoke = function(cmd, args, opts, done) {
var working = CORE.cwd(),
version = null,
force = false,
dirname = 'packages';
opts.on('working', function(k,v) { working = v; });
opts.on('version', function(k,v) { version = v; });
opts.on('force', function() { force = true; });
opts.on('no-force', function() { force= false; });
opts.on('dir', function(k,v) { dirname = v; });
var packageIds = opts.parse(args);
if (packageIds.length===0) {
return done(new Error("Package name required"));
}
exports.invoke = function(cmd, args, opts, done) {
var working = CORE.cwd(),
version = null,
force = false,
dirname = 'packages';
opts.on('working', function(k,v) { working = v; });
opts.on('version', function(k,v) { version = v; });
opts.on('force', function() { force = true; });
opts.on('no-force', function() { force= false; });
opts.on('dir', function(k,v) { dirname = v; });
var packageIds = opts.parse(args);
if (packageIds.length===0) {
return done(new Error("Package name required"));
}