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

base-cli

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-cli - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

lib/config.js

2

lib/cli.js
'use strict';
var debug = require('debug')('base:cli');
var debug = require('debug')('base:cli:commands');
var commands = require('./commands');

@@ -5,0 +5,0 @@

'use strict';
var path = require('path');
var normalize = require('../config');
var utils = require('../utils');
module.exports = function(app) {
return function(val, next) {
if (app.options.verbose) {
console.log('--config is not implemented yet.');
if (!utils.isObject(val)) {
console.error('config expects an object, cannot set "%s"', val);
process.exit(1);
}
var name = (this.base && this.base.name) || this.constructor.name.toLowerCase();
var cwd = this.cwd || process.cwd();
var pkg = utils.pkg.sync(cwd);
if (pkg === null) {
next(new Error('cannot find package.json'));
return;
}
var oldConfig = utils.get(pkg, name) || {};
val = utils.extend({}, oldConfig, val);
pkg[name] = normalize(this, val, oldConfig);
this.set('cache.pkg', pkg);
var pkgPath = path.resolve(cwd, 'package.json');
utils.writeJson.sync(pkgPath, pkg);
next();
};
};
'use strict';
var path = require('path');
/**

@@ -16,2 +18,5 @@ * Set the current working directory.

return function(val, next) {
val = path.resolve(val);
app.cwd = val;
if (typeof app.option === 'function') {

@@ -18,0 +23,0 @@ app.option('cwd', val);

'use strict';
var path = require('path');
var utils = require('../utils');
module.exports = function(app) {
return function(val, next) {
if (typeof app.store === 'undefined') {
next();
return function(obj, next) {
if (!utils.isObject(obj)) {
cb(new Error('save expects an object, cannot set "%s"', obj));
return;
}
app.store.set(val);
var name = (this.base && this.base.name) || this.constructor.name.toLowerCase();
var data = this.store.data;
if (!utils.isObject(data)) {
cb(new Error('the store command requires the base-store plugin to be registered'));
return;
}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var val = normalize(key, obj[key]);
var msg;
if (Array.isArray(val)) {
data[key] = data[key] || [];
utils.union(data[key], val);
msg = val.join(', ');
} else if (utils.isObject(val)) {
data[key] = utils.extend({}, data[key], val);
msg = JSON.stringify(data[key]);
} else {
data[key] = val;
msg = val;
}
console.log('global "%s" is now set to "%s"', key, msg);
}
}
this.store.set(data);
next();
};
};
function normalize(key, val) {
var arrayKeys = ['plugins', 'helpers', 'reflinks'];
if (~arrayKeys.indexOf(key)) {
if (typeof val === 'string') {
return [val];
}
if (utils.isObject(val)) {
for (var key in val) {
if (val.hasOwnProperty(key)) {
var value = val[key];
if (typeof value === 'boolean') {
return [key];
}
}
}
}
}
return val;
}

@@ -18,2 +18,3 @@ 'use strict';

// misc
require('empty-dir');
require('opn');

@@ -25,6 +26,12 @@ require('try-open');

require('kind-of', 'typeOf');
require('get-value', 'get');
require('set-value', 'set');
require('arr-union', 'union');
require('map-schema', 'Schema');
// naming
require('namify');
require('load-pkg', 'pkg');
require('project-name', 'project');
require('write-json');
require = fn;

@@ -41,2 +48,13 @@

/**
* Cast `val` to an array
*
* @param {String|Array} `val`
* @return {Array}
*/
utils.arrayify = function(val) {
return val ? (Array.isArray(val) ? val : [val]) : [];
};
/**
* Return true if a value is an object.

@@ -56,15 +74,6 @@ */

utils.isEmpty = function(dir, fn) {
var files;
try {
if (!utils.exists(dir)) {
return false;
}
files = fs.readdirSync(dir);
files = files.filter(fn || function(fp) {
return !/\.DS_Store/i.test(fp);
});
return files.length === 0;
} catch (err) {};
return true;
utils.isEmpty = function(dir) {
return utils.emptyDir(dir, function(fp) {
return !/\.DS_Store/i.test(fp);
});
};

@@ -71,0 +80,0 @@

{
"name": "base-cli",
"description": "Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.",
"version": "0.4.6",
"version": "0.4.7",
"homepage": "https://github.com/jonschlinkert/base-cli",

@@ -24,12 +24,19 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"arr-union": "^3.0.0",
"base-config": "^0.4.0",
"debug": "^2.2.0",
"empty-dir": "^0.2.0",
"export-files": "^2.1.1",
"extend-shallow": "^2.0.1",
"get-value": "^2.0.3",
"kind-of": "^3.0.2",
"lazy-cache": "^1.0.3",
"load-pkg": "^3.0.1",
"map-schema": "^0.1.1",
"namify": "^0.1.3",
"opn": "^4.0.0",
"project-name": "^0.2.4",
"try-open": "^0.1.0"
"set-value": "^0.3.3",
"try-open": "^0.1.0",
"write-json": "^0.2.2"
},

@@ -48,3 +55,4 @@ "devDependencies": {

"minimist": "^1.2.0",
"mocha": "*"
"mocha": "*",
"through2": "^2.0.0"
},

@@ -51,0 +59,0 @@ "keywords": [

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