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

base-generators

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-generators - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

71

index.js

@@ -30,2 +30,4 @@ /*!

this.isGenerator = true;
this.define('firstGen', null);
var resolveCache = {};

@@ -218,10 +220,19 @@ var globalCache = {};

if (getCache[name]) return getCache[name];
if (getCache[name]) {
return getCache[name];
}
var findGlobal = true;
var props = name.split('.');
var len = props.length;
var idx = -1;
var app = this;
var prop;
while ((prop = props.shift())) {
app = app.findGenerator(prop, fn);
if (!app) break;
while (++idx < len) {
var key = props[idx];
app = app.findGenerator(key, fn, findGlobal);
if (!app) {
break;
}
findGlobal = false;
}

@@ -272,3 +283,8 @@

this.define('findGenerator', function(name, fn) {
this.define('findGenerator', function(name, aliasFn, findGlobal) {
if (typeof aliasFn === 'boolean') {
findGlobal = aliasFn;
aliasFn = null;
}
debug('finding generator "%s"', name);

@@ -279,9 +295,25 @@ if (findCache[name]) {

fn = fn || this.toAlias.bind(this);
aliasFn = aliasFn || this.toAlias.bind(this);
var generator = this.generators.get(name, fn)
|| this.base.generators.get(name, fn)
|| this.globalGenerator(name);
// if sub-generator, look for it on the first resolved generator
if (this.firstGen && this.firstGen.generators[name]) {
var sub = this.firstGen.getGenerator(name, aliasFn);
if (sub) {
return sub;
}
}
// search for generator on the instance cache, then if not found
// search for the generator on the base instance's cache
var generator = this.generators.get(name, aliasFn)
|| this.base.generators.get(name, aliasFn);
// if global lookup is enabled, search global `node_modules`
if (!generator && findGlobal === true) {
generator = this.globalGenerator(name);
}
// if resolved, cache it
if (generator) {
if (!this.firstGen) this.firstGen = generator;
findCache[name] = generator;

@@ -390,5 +422,13 @@ return generator;

if (typeof name === 'string' && !/\W/.test(name)) {
var gen = this.getGenerator(name);
var app = this.getGenerator(name);
tasks = Array.isArray(tasks) ? tasks : ['default'];
return gen.build(tasks, cb);
if (tasks[0] === 'default' && !app.hasTask('default')) {
tasks = ['noop'];
app.task('noop', function(next) {
debug('running noop task');
delete app.tasks.noop;
next();
});
}
return app.build(tasks, build);
}

@@ -400,3 +440,2 @@ }

debug('no default tasks defined');
this.emit('task:skipping');
return cb();

@@ -412,3 +451,3 @@ }

var gen = res.generator;
var app = this;
var self = this;

@@ -427,3 +466,3 @@ if (typeof gen.config === 'undefined') {

if (err) {
generatorError(err, app, name, cb);
generatorError(err, self, name, cb);
} else {

@@ -544,3 +583,3 @@ cb();

* passed as the "parent" instance to the generator. The `base` getter
* ensures that the `base` instance is always the _first instance_.
* ensures that the `base` instance is always the firstGen instance_.
*

@@ -547,0 +586,0 @@ * ```js

@@ -16,2 +16,4 @@ 'use strict';

this.generators = new Cache();
// caches
var envCache = {};

@@ -135,2 +137,3 @@ var getCache = {};

debug('generators.get getting "%s"', name);
if (getCache[name]) return getCache[name];
fn = fn || utils.identity;

@@ -155,9 +158,4 @@

if (getCache[n]) {
return getCache[n];
}
if (seen[n]) {
continue;
}
if (getCache[n]) return getCache[n];
if (seen[n]) continue;
seen[n] = true;

@@ -180,4 +178,3 @@

if (error.name === 'ReferenceError') {
var stack = error.stack;
// console.log(generator.cwd)
return error;
}

@@ -184,0 +181,0 @@

@@ -31,6 +31,5 @@ 'use strict';

var isDefault = res.tasks[0] === 'default';
var isDefault = res.tasks.length === 1 && res.tasks[0] === 'default';
function ensureDefault(res) {
var generator = res.generator;
if (generator && !generator.hasTask('default')) {
if (res.generator && !res.generator.hasTask('default')) {
res.tasks = null;

@@ -41,2 +40,3 @@ }

if (!/\W/.test(prop) && gen.hasTask(prop)) {
debug('simple tasks "%s"', prop);
res.generator = gen;

@@ -53,2 +53,3 @@ res.tasks = [prop];

if (len > 1) {
debug('default tasks "%s"', prop);
res.generator = gen.getGenerator(segs[0]);

@@ -73,6 +74,6 @@ if (isDefault) {

// let composer handle the error
// let the `composer` lib handle it from here
res.generator = gen;
if (prop === 'default') {
res.tasks = null;
ensureDefault(res);
}

@@ -79,0 +80,0 @@ return res;

{
"name": "base-generators",
"description": "Adds project-generator support to your `base` application.",
"version": "0.1.8",
"version": "0.1.9",
"homepage": "https://github.com/jonschlinkert/base-generators",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

@@ -21,3 +21,3 @@ # base-generators [![NPM version](https://img.shields.io/npm/v/base-generators.svg)](https://www.npmjs.com/package/base-generators) [![Build Status](https://img.shields.io/travis/jonschlinkert/base-generators.svg)](https://travis-ci.org/jonschlinkert/base-generators)

_(TOC generated by [verb](https://github.com/verbose/verb))_
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

@@ -246,3 +246,3 @@ ## Install

### [.resolve](index.js#L74)
### [.resolve](index.js#L76)

@@ -279,3 +279,3 @@ Attempts to find a generator with the given `name` and `options`.

### [.register](index.js#L130)
### [.register](index.js#L132)

@@ -299,3 +299,3 @@ Register generator `name` with the given `fn`.

### [.generator](index.js#L154)
### [.generator](index.js#L156)

@@ -319,3 +319,3 @@ Register generator `name` with the given `fn`, or get generator `name` if only one argument is passed. This method calls the `.getGenerator` method but goes one step further: if `name` is not already registered, it will try to resolve and register the generator before returning it (or `undefined` if unsuccessful).

### [.hasGenerator](index.js#L186)
### [.hasGenerator](index.js#L188)

@@ -344,3 +344,3 @@ Return true if the given `name` exists on the `generators` object. Dot-notation may be used to check for sub-generators.

### [.getGenerator](index.js#L210)
### [.getGenerator](index.js#L212)

@@ -363,3 +363,3 @@ Get generator `name` from `app.generators`. Dot-notation may be used to get a sub-generator.

### [.globalGenerator](index.js#L243)
### [.globalGenerator](index.js#L254)

@@ -374,3 +374,3 @@ Search for globally installed generator `name`. If found, then generator

### [.findGenerator](index.js#L270)
### [.findGenerator](index.js#L281)

@@ -387,3 +387,3 @@ Find generator `name`, by first searching the cache,

### [.invoke](index.js#L301)
### [.invoke](index.js#L333)

@@ -403,3 +403,3 @@ Invoke the given generator in the context of (`this`) the current instance.

### [.extendWith](index.js#L338)
### [.extendWith](index.js#L370)

@@ -424,3 +424,3 @@ Alias for `.invoke`, Extend the current generator instance with the settings of other generators.

### [.generate](index.js#L376)
### [.generate](index.js#L408)

@@ -463,3 +463,3 @@ Run a `generator` and `tasks`, calling the given `callback` function upon completion.

### [.generateEach](index.js#L444)
### [.generateEach](index.js#L483)

@@ -483,3 +483,3 @@ Iterate over an array of generators and tasks, calling [generate](#generate) on each.

### [.alias](index.js#L468)
### [.alias](index.js#L507)

@@ -494,3 +494,3 @@ Create a generator alias from the given `name`.

### [.fullname](index.js#L488)
### [.fullname](index.js#L527)

@@ -505,3 +505,3 @@ Create a generator's full name from the given `alias`.

### [.configfile](index.js#L503)
### [.configfile](index.js#L542)

@@ -511,3 +511,3 @@ Getter/setter for defining the `configfile` name to use for lookups.

### [.modulename](index.js#L521)
### [.modulename](index.js#L560)

@@ -517,3 +517,3 @@ Getter/setter for defining the `modulename` name to use for lookups.

### [.base](index.js#L548)
### [.base](index.js#L587)

@@ -524,3 +524,3 @@ Getter/setter for the `base` (or shared) instance of `generate`.

passed as the "parent" instance to the generator. The `base` getter
ensures that the `base` instance is always the _first instance_.
ensures that the `base` instance is always the firstGen instance_.

@@ -580,2 +580,2 @@ **Example**

_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 09, 2016._
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 11, 2016._
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