base-generators
Advanced tools
Comparing version 0.2.11 to 0.2.12
17
index.js
@@ -160,4 +160,4 @@ /*! | ||
/** | ||
* Get generator `name` from `app.generators`. Dot-notation | ||
* may be used to get a sub-generator. | ||
* Get generator `name` from `app.generators` and invoke it with the current instance. | ||
* Dot-notation may be used to get a sub-generator. | ||
* | ||
@@ -200,4 +200,4 @@ * ```js | ||
/** | ||
* Find generator `name`, by first searching the cache, | ||
* then searching the cache of the `base` generator. | ||
* Find generator `name`, by first searching the cache, then searching the | ||
* cache of the `base` generator. Use this to get a generator without invoking it. | ||
* | ||
@@ -538,3 +538,4 @@ * ```js | ||
function extendGenerator(app, generator, res) { | ||
var alias = generator.env && generator.env.alias; | ||
var env = generator.env || {}; | ||
var alias = env.alias; | ||
@@ -552,3 +553,3 @@ // update `cache.config` | ||
var compose = generator | ||
.compose('default') | ||
.compose(['default']) | ||
.options(); | ||
@@ -569,2 +570,6 @@ | ||
} | ||
if (typeof app.question === 'function') { | ||
compose.questions(); | ||
} | ||
} | ||
@@ -571,0 +576,0 @@ } |
@@ -28,54 +28,2 @@ 'use strict'; | ||
utils.addLeaf = function(options) { | ||
return function addLeaf(app) { | ||
if (!this.isGenerator || this.isRegistered('addLeaf')) return; | ||
this.tree = {}; | ||
/** | ||
* Add a generator and its tasks to the tree object. Mostly used for | ||
* debugging, but also useful for logging out visual trees. | ||
* | ||
* ```js | ||
* this.addLeaf(generator.alias, generator); | ||
* ``` | ||
* @param {String} `name` | ||
* @param {Object} `app` | ||
*/ | ||
this.define('addLeaf', function(alias, generator) { | ||
this.tree[alias] = {}; | ||
this.tree[alias].tasks = Object.keys(generator.tasks || {}); | ||
this.tree[alias].generators = generator.tree; | ||
return this; | ||
}); | ||
/** | ||
* Define a getter/setter with a function value, where the function | ||
* is only called once, and it's value is returned. | ||
* | ||
* @param {Object} `obj` | ||
* @param {String} `prop` | ||
* @param {Function} `fn` | ||
* @return {any} | ||
* @api public | ||
*/ | ||
function define(obj, prop, fn) { | ||
var cached; | ||
Object.defineProperty(obj, prop, { | ||
configurable: true, | ||
enumarable: true, | ||
set: function(val) { | ||
cached = val; | ||
}, | ||
get: function() { | ||
return cached || fn(); | ||
} | ||
}); | ||
} | ||
return addLeaf; | ||
}; | ||
}; | ||
/** | ||
@@ -102,3 +50,5 @@ * Cast `val` to an array | ||
utils.exists = function(name) { | ||
if (existsCache[name]) return true; | ||
if (existsCache.hasOwnProperty(name)) { | ||
return existsCache[name]; | ||
} | ||
@@ -132,2 +82,4 @@ function set(name, fp) { | ||
} catch (err) {} | ||
existsCache[name] = false; | ||
return false; | ||
@@ -134,0 +86,0 @@ }; |
{ | ||
"name": "base-generators", | ||
"description": "Adds project-generator support to your `base` application.", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"homepage": "https://github.com/node-base/base-generators", | ||
@@ -25,5 +25,5 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"async": "^1.5.2", | ||
"base-compose": "^0.1.4", | ||
"base-compose": "^0.1.5", | ||
"base-cwd": "^0.1.6", | ||
"base-env": "^0.1.6", | ||
"base-env": "^0.1.7", | ||
"base-option": "^0.7.0", | ||
@@ -30,0 +30,0 @@ "base-pkg": "^0.2.2", |
@@ -24,4 +24,2 @@ # base-generators [](https://www.npmjs.com/package/base-generators) [](https://npmjs.org/package/base-generators) [](https://travis-ci.org/node-base/base-generators) | ||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_ | ||
## Install | ||
@@ -314,3 +312,3 @@ | ||
Get generator `name` from `app.generators`. Dot-notation may be used to get a sub-generator. | ||
Get generator `name` from `app.generators` and invoke it with the current instance. Dot-notation may be used to get a sub-generator. | ||
@@ -333,3 +331,3 @@ **Params** | ||
Find generator `name`, by first searching the cache, then searching the cache of the `base` generator. | ||
Find generator `name`, by first searching the cache, then searching the cache of the `base` generator. Use this to get a generator without invoking it. | ||
@@ -420,3 +418,3 @@ **Params** | ||
### [.generateEach](index.js#L585) | ||
### [.generateEach](index.js#L590) | ||
@@ -440,3 +438,3 @@ Iterate over an array of generators and tasks, calling [generate](#generate) on each. | ||
### [.toAlias](index.js#L637) | ||
### [.toAlias](index.js#L642) | ||
@@ -566,14 +564,2 @@ Create a generator alias from the given `name`. By default the alias is the string after the last dash. Or the whole string if no dash exists. | ||
### [define](lib/utils.js#L62) | ||
Define a getter/setter with a function value, where the function | ||
is only called once, and it's value is returned. | ||
**Params** | ||
* `obj` **{Object}** | ||
* `prop` **{String}** | ||
* `fn` **{Function}** | ||
* `returns` **{any}** | ||
## Related projects | ||
@@ -632,2 +618,2 @@ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 03, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 07, 2016._ |
49409
952
612
Updatedbase-compose@^0.1.5
Updatedbase-env@^0.1.7