Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

verb-util

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

verb-util - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+3
.travis.yml
language: node_js
node_js:
- '0.10'
# {%= name %} {%= badge("fury") %}
> {%= description %}
## Install
{%= include("install-npm", {save: true}) %}
## Run tests
```bash
npm test
```
## Usage
```js
var utils = require('{%= name %}');
```
## API
{%= comments("index.js") %}
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %})
## Author
{%= include("author") %}
## License
{%= copyright() %}
{%= license() %}
***
{%= include("footer") %}
'use strict';
var extract = require('extract-gfm');
/**
* Adjust markdown heading levels.
*
* Adds one heading level next to all markdown headings to make
* them correct within the scope of the inheriting document.
* _Headings in fenced code blocks are skipped_.
*
* ```js
* utils.heading(str);
* ```
*
* @param {String} `str`
* @return {String}
* @api public
*/
module.exports = function(str, lvl) {
var o = extract.parseBlocks(str);
lvl = lvl ? new Array(lvl + 2).join('#') : '##';
o.text = o.text.replace(/^#/gm, lvl);
return extract.injectBlocks(o.text, o.blocks);
};
'use strict';
var fs = require('fs');
var path = require('path');
fs.readdirSync(__dirname).forEach(function (name) {
var base = path.basename(name, path.extname(name));
var fp = path.resolve(__dirname, name);
if (!/index/.test(fp) && fs.statSync(fp).isFile()) {
exports[base] = require(fp);
}
});
/*!
* verb-util <https://github.com/jonschlinkert/verb-util>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
var assert = require('assert');
var should = require('should');
var utils = require('./');
describe('utils', function () {
describe('.headings()', function () {
it('should skip fenced code blocks:', function () {
utils.headings('```js\n# Foo\n```\n# Bar').should.eql('```js\n# Foo\n```\n\n## Bar');
});
it('should add one heading level:', function () {
utils.headings('# Bar').should.eql('## Bar');
utils.headings('## Bar').should.eql('### Bar');
utils.headings('### Bar').should.eql('#### Bar');
});
it('should add the specified number of heading levels:', function () {
utils.headings('# Bar', 1).should.eql('## Bar');
utils.headings('# Bar', 2).should.eql('### Bar');
utils.headings('# Bar', 3).should.eql('#### Bar');
utils.headings('# Bar', 4).should.eql('##### Bar');
});
});
});
+3
-1
{
"esnext": true,
"asi": false,
"boss": true,

@@ -7,4 +7,6 @@ "curly": true,

"eqnull": true,
"esnext": true,
"immed": true,
"latedef": true,
"laxcomma": false,
"newcap": true,

@@ -11,0 +13,0 @@ "noarg": true,

@@ -8,5 +8,4 @@ /*!

module.exports = {
glob: require('./lib/glob'),
read: require('./lib/read'),
};
'use strict';
module.exports = require('./lib');
{
"name": "verb-util",
"description": "Utilities for Verb, for plugins and tags.",
"version": "0.1.0",
"description": "Utilities for verb, and verb helpers, plugins, or other extensions.",
"version": "0.1.1",
"homepage": "https://github.com/jonschlinkert/verb-util",

@@ -23,11 +23,2 @@ "author": {

],
"keywords": [
"docs",
"documentation",
"generate",
"generator",
"markdown",
"templates",
"verb"
],
"main": "index.js",

@@ -41,12 +32,19 @@ "engines": {

"devDependencies": {
"chai": "~1.9.1",
"mocha": "*",
"verb": "~0.2.6",
"verb-readme-includes": "^0.1.18"
"should": "^4.3.0"
},
"keywords": [
"util",
"utils",
"utility",
"utilities",
"helper",
"extension",
"verb",
"plugin",
"verbutil"
],
"dependencies": {
"cwd": "^0.3.3",
"fs-utils": "^0.4.3",
"lodash": "^2.4.1"
"extract-gfm": "^0.1.0"
}
}

@@ -1,12 +0,30 @@

# verb-util [![NPM version](https://badge.fury.io/js/verb-util.png)](http://badge.fury.io/js/verb-util)
# verb-util [![NPM version](https://badge.fury.io/js/verb-util.svg)](http://badge.fury.io/js/verb-util)
> Utilities for Verb, for plugins and tags.
> Utilities for verb, and verb helpers, plugins, or other extensions.
## Install
Install with [npm](npmjs.org):
### Install with [npm](npmjs.org)
```bash
npm i verb-util --save-dev
npm i verb-util --save
```
## Run tests
```bash
npm test
```
## Usage
```js
var utils = require('verb-util');
```
## API
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/verb-util/issues)
## Author

@@ -20,3 +38,3 @@

## License
Copyright (c) 2014 Jon Schlinkert, contributors.
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license

@@ -26,2 +44,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 04, 2014._
_This file was generated by [verb](https://github.com/jonschlinkert/verb) on November 11, 2014._
# {%= name %} {%= badge('fury') %}
> {%= description %}
## Install
{%= include("install") %}
## Author
{%= include("author") %}
## License
{%= copyright() %}
{%= license() %}
***
{%= include("footer") %}
/*!
* verb-util <https://github.com/jonschlinkert/verb-util>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
'use strict';
var path = require('path');
var file = require('fs-utils');
var root = require('cwd')();
var _ = require('lodash');
/**
* ## glob()
*
* Returns a function to glob files.
*
* **Example**
*
* ```js
* var glob = require('verb-util').glob();
* console.log(glob('LICENSE-MIT'));
*
* // Set the cwd, so that any time the `glob` function is used
* // the file path will be relative to that directory
* var glob = require('verb-util').glob('test/fixtures');
* console.log(glob('foo.md')); // e.g. test/fixtures/foo.md
* ```
*
* @param {String} `cwd` Optionally pass a cwd.
* @return {String} the contents of the file.
*/
module.exports = function (cwd) {
cwd = cwd || root;
return function (patterns, options) {
var options = _.extend({cwd: cwd}, options);
return file.find(patterns, options).map(function(filepath) {
return file.normalizeSlash(path.join(cwd, filepath));
});
};
};
/*!
* verb-util <https://github.com/jonschlinkert/verb-util>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
'use strict';
var path = require('path');
var file = require('fs-utils');
var root = require('cwd');
/**
* ## read()
*
* Returns a function to read a file, which in turn returns the contents of the specified file.
*
* **Example**
*
* ```js
* var read = require('verb-util').read();
* console.log(read('LICENSE-MIT'));
*
* // Set the cwd, so that any time the `read` function is used
* // the file path will be relative to that directory
* var read = require('verb-util').read('test/fixtures');
* console.log(read('foo.md')); // e.g. test/fixtures/foo.md
* ```
*
* @param {String} `cwd` Optionally pass a cwd.
* @return {String} the contents of the file.
*/
module.exports = function (cwd) {
return function (filepath, options) {
var fullpath = path.join(cwd || root(), filepath);
return file.readFileSync(fullpath, options);
};
};
contents of test.txt

Sorry, the diff of this file is not supported yet

/*!
* ut <https://github.com/jonschlinkert/ut>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
var expect = require('chai').expect;
var vutil = require('../');
describe('read():', function () {
var fixtures = vutil.read('test/fixtures');
it('should convert foo to bar.', function () {
var fixture = fixtures('test.txt');
expect(/^contents/.test(fixture)).to.eql(true);
});
});
describe('glob():', function () {
it('should return an array of files.', function () {
var files = vutil.glob()('lib/*.js');
expect(files).to.be.an('array');
expect(files.length).to.be.above(1);
});
it('should use the cwd.', function () {
var files = vutil.glob('lib')('*.js');
expect(files).to.be.an('array');
expect(files.length).to.be.above(1);
});
it('should use the cwd.', function () {
var files = vutil.glob(require('verb-readme-includes'))('*.md');
expect(files).to.be.an('array');
expect(files.length).to.be.above(0);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet