https://github.com/toddself/commonjs-concat
Output a single file to export all files in a directory structure
https://github.com/toddself/commonjs-concat
Last synced: 2 months ago
JSON representation
Output a single file to export all files in a directory structure
- Host: GitHub
- URL: https://github.com/toddself/commonjs-concat
- Owner: toddself
- License: other
- Created: 2015-05-04T19:57:07.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-04T20:40:11.000Z (about 11 years ago)
- Last Synced: 2025-03-15T05:12:00.858Z (over 1 year ago)
- Language: JavaScript
- Size: 101 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://travis-ci.org/toddself/commonjs-concat)
# commonjs-concat
Take a directory of files and create a single file which exports all the files in the directory structure.
## Usage
### CLI
```
$ npm i -g commonjs-concat
$ tree test/fixtures
test/fixtures
├── more
│ └── testing.js
├── test-file-1.js
├── test_file-2.js
└── testing.json
$ cjs-concat test/fixtures
exports.testFile1 = require('/Users/todd/src/commonjs-concat/test/fixtures/test-file-1.js');
exports.testFile2 = require('/Users/todd/src/commonjs-concat/test/fixtures/test_file-2.js');
exports.testing = require('/Users/todd/src/commonjs-concat/test/fixtures/more/testing.js');
# cjs-concat test/fixtures --no-relative -f"*json"
exports.testFile1 = require('./test-file-1.js');
exports.testFile2 = require('./test_file-2.js');
exports.testing = require('./testing.json');
exports.testing1 = require('./more/testing.js');
```
```
Usage:
cjs-concat PATH [options]
Options:
-h, --help print usage information
-v, --version show version info and exit
-o, --output Write output to file, default: stdout
-d, --ignoreDir Ignore directories, default: node_modules
-f, --includeFile Include other file patterns. default: *.js
--no-relative Make paths relative to PATH
```
### API
```js
> var concat = require('commonjs-concat');
> concat('test/fixtures', {includeFile: '*json', relative: false}, function(err, output) {
console.log(output);
});
exports.testFile1 = require('./test-file-1.js');
exports.testFile2 = require('./test_file-2.js');
exports.testing = require('./testing.json');
exports.testing1 = require('./more/testing.js');
```
### Licence
Copyright 2015 Todd Kennedy, Apache 2 license