Storage

new Storage(name, fs, configPath)

Storage instances handle a json file where Generator authors can store data.

Base instantiate the storage as config by default.

Parameters:
Name Type Description
name String

The name of the new storage (this is a namespace)

fs mem-fs-editor

A mem-fs editor instance

configPath String

The filepath used as a storage.

Example
var MyGenerator = yeoman.base.extend({
  config: function() {
    this.config.set('coffeescript', false);
  }
});

Methods

_persist(val)

Persist a configuration to disk

Parameters:
Name Type Description
val Object

current configuration values

defaults(defaults) → {*}

Setup the store with defaults value and schedule a save. If keys already exist, the initial value is kept.

Parameters:
Name Type Description
defaults Object

Key-value object to store.

Returns:
* -

val Returns the merged options.

delete(key) → {null}

Delete a key from the store and schedule a save.

Parameters:
Name Type Description
key String

The key under which the value is stored.

Returns:
null

get(key) → {*}

Get a stored value

Parameters:
Name Type Description
key String

The key under which the value is stored.

Returns:
* -

The stored value. Any JSON valid type could be returned

getAll() → {Object}

Get all the stored values

Returns:
Object -

key-value object

save() → {null}

Save a new object of values

Returns:
null

set(key, val) → {*}

Assign a key to a value and schedule a save.

Parameters:
Name Type Description
key String

The key under which the value is stored

val *

Any valid JSON type value (String, Number, Array, Object).

Returns:
* -

val Whatever was passed in as val.