An open API service indexing awesome lists of open source software.

https://github.com/tecfu/file_get_contents_sync

Nodejs module to get the contents of a directory or a file synchronously. Returns result as a javascript object or a flattened string. Can be run as a node module or in CLI.
https://github.com/tecfu/file_get_contents_sync

Last synced: about 1 year ago
JSON representation

Nodejs module to get the contents of a directory or a file synchronously. Returns result as a javascript object or a flattened string. Can be run as a node module or in CLI.

Awesome Lists containing this project

README

          

file_get_contents_sync
======================

Nodejs module to get the contents of a directory or a file synchronously.

## Usages:

### Node Module

- Return the contents of all matched files as a js object:

```
require("file_get_contents_sync")("/path/to/somedir");

//{path1:"...contents...",path2:function(){}}
```

- Return the contents of all matched files as a single string:

```
require("file_get_contents_sync")("/path/to/somedir","string");

//"...contents...function(){}"
```

### Command line :

- Return the contents of all matched files as a js object:

```
$ node node_modules/file_get_contents_sync/src/main.js /path/to/js
```

- Return the contents of all matched files as a single string:

```
$ node node_modules/file_get_contents_sync/src/main.js /path/to/html string
```