Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-require-files

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-require-files

grunt plugin to generate AMD requires for listed files

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

grunt-require-files

grunt plugin to generate AMD requires for listed files

I wrote this as a hack to generate a valid javascript source file declaring require() of file-globbed modules which I could load into a QUnit test runner that was being run via the grunt-qunit-istanbul plugin. The grunt-qunit-istanbul plugin only instruments (for coverage metrics) those source files which were loaded by the qunit test runner; therefore if your QUnit test modules did require all of your sources, you would be mislead into thinking you were covering more than you actually were.

Getting Started

This plugin requires Grunt.

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-require-files --save-dev

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

grunt.loadNpmTasks('grunt-require-files');

The "require_files" task

Overview

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

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

Options

options.relativeTo

Type: String Default value: ./

A string value representing a path (to a directory or file), from which the required modules would be relative'ly loaded from.

options.callback

Type: String Default value: ''

A string value representing the callback function that would be invoked when the require()'d modules successfully load.

options.extraModules

Type: Array Default value: []

An array of module names to also load.

Usage Examples

Default Options

In this example, we have a test runner at test/js/tests.html, source modules in src/js, and test specs in test/js/specs that end in Spec.js. Additionally, we will require two extra modules: ModuleA and ModuleB.

grunt.initConfig({
  require_files: {
    options: {
      relativeTo: 'test/js/tests.html'
      callback: 'QUnit.start',
      extraModules: ['ModuleA', 'ModuleB']
    },
    files: {
      'build/test-requires.js': ['src/js/**/*.js', 'test/js/specs/**/*Spec.js'],
    },
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 0.0.1 Initial release
  • 0.0.2 Add support for extra modules to require

License

Copyright (c) 2014 Kevin Mudrick. Licensed under the MIT license.

Keywords

FAQs

Package last updated on 20 Aug 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