# grunt-stubbify

> Grunt version of stubbify (https://github.com/isibner/stubbify)

Latest version **0.2.1** (published 2015-01-24) · 0 weekly downloads

## Install

```sh
npm install grunt-stubbify
pnpm add grunt-stubbify
yarn add grunt-stubbify
bun add grunt-stubbify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-01-24 |
| First published | 2014-12-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ian Sibner |
| Maintainers | isibner |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-stubbify
- Repository: https://github.com/isibner/grunt-stubbify
- Issues: https://github.com/isibner/grunt-stubbify/issues
- npm.io page: https://npm.io/package/grunt-stubbify

## Dependencies (2)

- [highland](https://npm.io/package/highland.md) ^2.2.0
- [stubbify](https://npm.io/package/stubbify.md) ^0.1.0

## Recent versions

- 0.2.1 (latest) — 2015-01-24
- 0.2.0 — 2015-01-10
- 0.1.0 — 2014-12-30

## README

# grunt-stubbify
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]

> Grunt version of [stubbify](https://github.com/isibner/stubbify)

## Getting Started
This plugin requires Grunt `~0.4.5`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out its [Getting Started](http://gruntjs.com/getting-started) guide. It explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) and how to install, [configure](http://gruntjs.com/configuring-tasks), and use Grunt plugins.

## Installation

```shell
npm install grunt-stubbify --save-dev
```

Once the plugin has been installed, enable it in your Gruntfile with:
```js
grunt.loadNpmTasks('grunt-stubbify');
```

## The "stubbify" task

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

```js
grunt.initConfig({
  stubbify: {
    options: {
      beginStub: /^.*\/\/[\s]*STUB/i,
      endStub: /^.*\/\/[\s]*ENDSTUB/i,
      verbose: true
    },
    src: ['src/test.js'],
    dest: 'stubs/'
  }
});
```

### Options

#### options.beginStub
Type: `RegExp`
Default value: `/^.*\/\/[\s]*STUB/i`

Regular expression for the beginning of stubbed-out portions. The default matches '// STUB'.

#### options.endStub
Type: `RegExp`
Default value: `/^.*\/\/[\s]*ENDSTUB/i`

Regular expression for the end of the stubbed-out portion. The default  matches '// ENDSTUB'.

#### options.verbose
Type: `boolean`
Default value: `true`

Indicates whether a success log should be printed for each stubbified file.

### Usage Examples

#### Default Options
```js
grunt.initConfig({
  stubbify: {
    src: ['src/test.js'],
    dest: 'stubs/'
  }
});
```

Here, we use the default options to stub JavaScript files. If `src/test.js` contains:
```js
var add = function (a, b) {
  // add the two input integers together
  // STUB
  return a + b;
  // ENDSTUB
}

```
then the generated `stubs/src/test.js` will contain:
```js
var add = function (a, b) {
  // add the two input integers together
}

```

#### Custom Options
```js
grunt.initConfig({
  stubbify: {
    options: {
      beginStub: /<\!--[\s]*STUB[\s]*-->/i,
      endStub: /<\!--[\s]*ENDSTUB[\s]*-->/i
    },
    src: ['src/test.html'],
    dest: 'stubs/'
  }
});
```
In this example, we use the `beginStub` and `endStub` options to stub out an HTML file. If `src/test.html` contains:
```html
<div>
  <!-- STUB -->
  <p>hello world</p>
  <!-- ENDSTUB -->
</div>

```
then the generated `stubs/src/test.html` will contain:
```html
<div>
</div>

```

#### Grunt Options
```js
grunt.initConfig({
  stubbify: {
    html: {
      options: {
        beginStub: /<\!--[\s]*STUB[\s]*-->/i,
        endStub: /<\!--[\s]*ENDSTUB[\s]*-->/i
      },
      files: {
        'stubs/': ['src/test.html']
      }
    },
    js: {
      files: {
        'stubs/': ['src/test.js']
      }
    }
  }
});
```
In this example, we specify multiple targets `js` and `html` for the `stubbify` task, and we use the `files` object in lieu of the `src` and `dest` keys used above.

## 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.1.0 - Initial Release

[npm-image]: https://img.shields.io/npm/v/grunt-stubbify.svg?style=flat
[npm-url]: https://www.npmjs.com/package/grunt-stubbify
[travis-image]: https://img.shields.io/travis/isibner/grunt-stubbify.svg?style=flat
[travis-url]: https://travis-ci.org/isibner/grunt-stubbify

---
_Source: https://npm.io/package/grunt-stubbify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
