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

grunt-dump-dir

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-dump-dir

Grunt task to dump a dictionary (all files and their content) into a JSON object

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

grunt-dump-dir Build Status NPM version

Grunt task to dump a dictionary (all files and their content) into a JSON object

grunt-dump-dir lets you select a directory and generates a JSON representation with keys being filepaths and values - their content encoded in base64.

The main use case for this plugin is virtual filesystem generation for browserify projects.

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-dump-dir --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-dump-dir');

Dump Dir task

In your project's Gruntfile, add a section named dump_dir to the data object passed into grunt.initConfig().

grunt.initConfig({
  dump_dir: {
    options: {
      // options
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.rootPath

Type: String Default value: ``

A string value which is trimmed from physical path when JSON keys are created.

options.pre

Type: string Default value: module.exports =

String which prefixes generated JSON. Should be used to specify the assignment. The default module.exports = is not very functional unless the file is used as input to browserify.

Usually you should set it to something like var myVariable =

Usage Examples

Default Options

If you don't specify options.rootPath:

grunt.initConfig({
  dump_dir: {
    options: {
    },
    files: {
      'dest.js': [ 'directory/**/*' ]
    },
  },
});

the output will contain full-path keys:

{
 "directory/filename.txt": "base64-encoded-content",
 "directory/filename2.jpg": "base64-encoded-content"
}
RootPath

If rootPath is provided:

grunt.initConfig({
  dump_dir: {
    options: {
      'rootPath': 'directory/'
    },
    files: {
      'dest.js': [ 'directory/**/*' ]
    },
  },
});

we'll get the following JSON:

{
 "filename.txt": "base64-encoded-content",
 "filename2.jpg": "base64-encoded-content"
}

Keywords

FAQs

Package last updated on 10 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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