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

lz-node-utils

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lz-node-utils - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

CHANGELOG.md

1

grunt/config/vars.js

@@ -8,4 +8,5 @@ module.exports = {

'lib/**/*.js',
'test/**/*.js'
]
}
};

3

lib/util.js

@@ -9,4 +9,5 @@ module.exports = ( function() {

ucwords: require( './ucwords' ),
_deepExtend: require( './deepExtend' )
_deepExtend: require( './deepExtend' ),
expandSourceFiles: require( './expandSourceFiles' )
};
}() );
{
"name": "lz-node-utils",
"version": "0.1.8",
"version": "0.1.9",
"description": "Useful utility functions for node.",

@@ -12,5 +12,7 @@ "main": "lib/util.js",

"underscore": "^1.7.0",
"yaml-front-matter": "lzilioli/js-yaml-front-matter#182516d"
"yaml-front-matter": "git+https://github.com/lzilioli/js-yaml-front-matter#182516d"
},
"devDependencies": {
"chai": "^1.10.0",
"comparejs": "^0.1.2",
"grunt": "^0.4.5",

@@ -20,4 +22,7 @@ "grunt-contrib-jshint": "^0.10.0",

"grunt-jsbeautifier": "^0.2.7",
"grunt-release": "^0.9.0",
"grunt-shell": "^1.1.1",
"jshint-stylish": "^1.0.0",
"load-grunt-config": "^0.16.0",
"mocha": "^2.0.1",
"shelljs": "^0.3.0"

@@ -33,3 +38,7 @@ },

},
"homepage": "https://github.com/lzilioli/lz-node-utils"
"homepage": "https://github.com/lzilioli/lz-node-utils",
"scripts": {
"test": "./node_modules/.bin/mocha --reporter spec test/test.js"
},
"license": "MIT"
}

@@ -9,3 +9,3 @@ lz-node-utils

```bash
npm install --save-dev git+http://git@github.com/lzilioli/lz-node-utils.git
npm install --save lz-node-utils
```

@@ -23,2 +23,4 @@

**THEY ARE ALL SYNCHRONOUS**
- `file.expand`

@@ -32,4 +34,18 @@ - `file.expandMapping`

### `util.reqfn(rootDir)`
### `util.pth`
Like path.join, but returns an absolute path to the referenced location.
```javascript
util.pth('grunt/config/file.json'); // returns /path/to/repo/grunt/config/file.json
util.pth('grunt', 'config', 'file.json'); // also returns /path/to/repo/grunt/config/file.json
util.pth('grunt/', '/config', '//', '/file.json'); // also returns /path/to/repo/grunt/config/file.json
```
**Disclaimer**
The absolute path returned is determined by prepending `process.cwd()` to the arguments that are passed to the function, and passing the result to `path.join()`. This is known to be effective for locally developed node applications, but has not been tested in a server environment, for globally installed npm modules, or in a Dockerized environment. Use at your own risk, but also if you run into an issue, let me know. I'd like this to be more versitle.
### `util.getReqfn(rootDir)`
Returns a function that, when called, will require a module relative to `rootDir`.

@@ -49,12 +65,10 @@

### `util.pth`
**Note**
Like path.join, but returns an absolute path to the referenced location.
This function relies on `util.path()` under the hood, so please be aware of the disclaimer (above) if using `util.getReqFn()`.
```javascript
util.pth('grunt/config/file.json'); // returns /path/to/repo/grunt/config/file.json
util.pth('grunt', 'config', 'file.json'); // also returns /path/to/repo/grunt/config/file.json
util.pth('grunt/', '/config', '//', '/file.json'); // also returns /path/to/repo/grunt/config/file.json
```
### `util._deepExtend(_)`
Extends the passed instance of `_` with a deepExtend function, which works like extend, but does so recursively.
### `util.loadAppSettings(<defaultSettingsPath>, <userSettingsPath>)`

@@ -64,2 +78,4 @@

Unlike most libraries' extend function, this works with nested settings objects. It uses the `deepExtend()` function added to underscore by `util._deepExtend()`
Arguments default to `config/default-settings.js` and `config/settings.js`, respectively.

@@ -71,16 +87,39 @@

### `util._deepExtend(_)`
### `util.expandSourceFiles(sourceFiles)`
Extends the passed instance of `_` with a deepExtend function, which works like extend, but does so recursively.
The **`sourceFiles`** argument should be an object containing key/value pairs, where each value specifies a set of files associated with the given key.
You can specify values in 1 of 3 ways:
# Version History
1. string - `'templates/**/*.tmpl'`
2. array - `[ 'templates/**/*.tmpl', 'templates/**/*.handlebars' ]`
3. object - This will be converted to an array of string (argument type 2), where each value corresponds to a value in src with cwd prepended to it.
```javascript
{
cwd: 'templates/',
src: '**\/*.tmpl' // can also be an array
}
```
- v0.1.0 - Initial release
- v0.1.1 - added `util.reqFn`, `util.pth`, and `util.loadAppSettings`
- v0.1.2 - added `util.stripYamlFront`
- v0.1.4 - added `util.ucwords`
- v0.1.5 - added `util._deepExtend`
- v0.1.6 - `util.loadAppSettings` now behaves as expected with nested objects
- v0.1.7 ~~upgrade to latest `yaml-front-matter` (with my [pull request](https://github.com/dworthen/js-yaml-front-matter/pull/1)!)~~
- v0.1.8 Use my fork of `js-yaml-front-matter`, which npm installs cleanly.
This argumt ultimately gets passed to `util.file.expand()` to build out a list of existing files that match the passed argument.
Each key in sourceFiles will be converted to an object of the form:
```javascript
{ contents: <file contents>,
path: <relative path to file from cwd>,
fqp: <fully qualified path to file>
}
```
**Example**
```javascript
// if in templates/ directory you have template1.tmpl and template2.tmpl
util.expandSourceFiles({
templates: [ 'templates/**/*.tmpl' ]
});
// returns [ 'templates/template1.tmpl', 'templates/template2.tmpl' ]
```

Sorry, the diff of this file is not supported yet

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