Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
deps-object
Advanced tools
Transform dependencies Array into an Object
npm install --save deps-object
import depsObject from 'deps-object';
depsObject(['ava', 'nyc@^6.0.0', 'rimraf@2.5.2', '@sindresorhus/df'])
.then(item => console.log(item));
/* {
"@sindresorhus/df": "^1.0.1",
"ava": "^0.12.0",
"nyc": "^6.0.0",
"rimraf":"'2.5.2".
} */
var yeoman = require('yeoman-generator');
var objectAssign = require('object-assign');
var depsObject = require('deps-object');
var sortedObject = require('sorted-object');
module.exports = yeoman.Base.extend({
constructor: function () {
yeoman.Base.apply(this, arguments);
// your generator's initialization
// saveDepsToPkg helper
this.saveDepsToPkg = function (deps) {
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
var currentDeps = pkg.devDependencies || {};
var mergedDeps = objectAssign({}, currentDeps, deps);
var sortedDeps = sortedObject(mergedDeps);
pkg.devDependencies = sortedDeps;
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
};
},
writing: function () {
// your generator's file system operations
var deps = ['assert@^1.3.0', 'mocha@^2.4.5'];
return depsObject(deps)
.then(function(devDependencies) {
this.saveDepsToPkg(devDependencies);
}.bind(this))
.catch(function (err) { throw err; });
}
});
// depsObject :: Array[String] -> Promise Object`
Return a promise that resolves to dependencies object.
Required
Type: Array[String]
Dependencies list. Specify dependency with @
, otherwise result version will be latest one with ^
prefix.
MIT © Vladimir Starkov
FAQs
Transform dependencies Array into an Object
We found that deps-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.