deps-object
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "deps-object", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Transform dependencies Array into an Object", | ||
@@ -5,0 +5,0 @@ "main": "index.es5.js", |
@@ -29,2 +29,41 @@ # deps-object | ||
## Usage with yeoman generators | ||
```js | ||
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; }); | ||
} | ||
}); | ||
``` | ||
## API | ||
@@ -31,0 +70,0 @@ |
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
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
6216
98