gulp-storage

A plugin for Gulp

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
gulp-storage
501.0.610 years ago10 years agoMinified + gzip package size for gulp-storage in KB

Readme

gulp-storage

storage plugin for gulp
Features
  • Gulp Storage uses Yeoman-Generator's storage plugin to simply save configurations in a local JSON file.
  • Bind's a storage property to the the gulp instance.
  • Within any gulp task, you can access the storage property by calling this.storage.

Usage

First, install gulp-storage as a development dependency:
npm install --save-dev gulp-storage

Then, add it to your gulpfile.js:
// require gulp
var gulp = require('gulp');

// Do this
var storage = require('gulp-storage')(gulp);

// or do this
require('gulp-storage')(gulp);

gulp.storage.create('SomeName', 'somName.json');

gulp.task( 'any', ['anotherTask'] function(){
    var appName = this.storage.get('appName');
    console.log(appName)
    //=> myApp
});

gulp.task('anotherTask', function(){
    this.storage.set('appName', 'myApp');
});

API

storage.create( name, fileName );

name

  • Type: String
    Default: myApp
  • Required: true

The name property will be the root object key for anything set in your local storage file.

fileName

  • Type: String
  • Default: myApp.json
  • Required: true
  • extension: .json

The gulp-storage will create a Json file in your local directory, using the specified name;
Note If you are using gulp-storage with a SlushJS Generator, gulp-storage will create the json file in the generated directory. The path will be process.cwd();

storage.set( key, value );

key

Type: String Required: true

value

Type: String
Required: true
storage.set will set a new property in your local storage file.

storage.get( key );

key

Type: String Required: false
storage.get will retreive values from your local storage file.
  • You can pass a key property to get a specific value.
  • If no key is specified, storage.get will return everything in your local storage file.

storage.store( object );

object

Type: Object Required: true
storage.store will set all properties and values within the object in your local storage file.

TODO

  • Create a storage.clear(); // Delete everything
  • Create a storage.delete( key ); // Delete a specific property

License

MIT License