Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
test
coverage.html
lib-cov
.jshintrc
.editorconfig

View File

@@ -0,0 +1,23 @@
validate: lint test
test:
@./node_modules/.bin/mocha \
--require should \
--reporter spec
test-cov: lib-cov
@CONCAT_COV=1 ./node_modules/.bin/mocha \
--require should \
--reporter html-cov > coverage.html
lint:
@./node_modules/.bin/jshint \
--verbose \
--config .jshintrc \
lib/*.js \
test/*.js
lib-cov:
jscoverage lib lib-cov
.PHONY: test lint

View File

@@ -0,0 +1,11 @@
0.0.2 / 2017-01-22
==================
* Point the 'globs' dependency to NPM instead of github
* add repo to package.json
0.0.1 / 2013-04-29
==================
* Initial release

View File

@@ -0,0 +1,3 @@
module.exports = process.env.CONCAT_COV
? require('./lib-cov/concatenate')
: require('./lib/concatenate');

View File

@@ -0,0 +1,132 @@
'use strict';
/*!
* concatenate dependencies
*/
var fs = require('fs')
, globs = require('globs');
/**
* Simple callback generator for `concatenate()`
*
* @api private
* @param {String} file
* @return {Function}
*/
function makeCb(file) {
return function (err, data) {
if (err) {
throw err;
}
fs.writeFileSync(file, data);
};
}
/**
* Concatenate files and such. Will maintain order of files.
*
* Examples:
*
* ```js
* // write all logs to `logs.txt`
* concatenate([ '*.txt', '*.log' ], 'logs.txt');
*
* // output the contents of all local javascript files
* concatenate('*.js', function (err, js) {
* if (err) throw err;
*
* console.log(js);
* });
* ```
*
* @api public
* @param {String|Array} patterns Files/wildcard patterns to concatenate
* @param {String|Function} cb File to write or callback
*/
var concatenate = module.exports = function (patterns, cb) {
// concatenate('*.txt', function () { ... })
if (!Array.isArray(patterns)) {
patterns = [ patterns ];
}
// concatenate([ '*.txt' ], 'all-text.js')
if (typeof cb === 'string') {
cb = makeCb(cb);
}
globs(patterns, function (err, files) {
if (err) {
return cb(err);
}
var done = false
, res = [];
/**
* Add the `file` at the `index` to the stack
*
* Will add the next `file` at `index++`, or fire
* `cb` if there is not another `file`.
*
* This is rather ugly, but maintains order
* of the provided files.
*
* @api private
* @param {Number} index
*/
function add(index) {
var file = files[index];
if (!file) {
done = true;
return cb(new Error('Invalid file "' + file + '"'));
}
fs.readFile(files[index], 'utf-8', function (err, data) {
if (done) { return; }
if (err) {
done = true;
return cb(err);
}
res.push(data);
index++;
if (!files[index]) {
done = true;
cb(null, res.join('\n'));
} else {
add(index);
}
});
}
// start the loop by adding the first file
add(0);
});
};
/**
* Synchronously concatenate files and such
*
* @api public
* @param {String|Array} patterns
* @param {String} [out] Output file
*/
concatenate.sync = function (patterns, out) {
var index
, files = globs.sync(patterns)
, length = files.length
, all = [];
for (index = 0; index < length; index++) {
all.push(fs.readFileSync(files[index], 'utf-8'));
}
all = all.join('\n');
if (out) {
// write file
fs.writeFileSync(out, all);
}
// return concatenated stuff
return all;
};

View File

@@ -0,0 +1,53 @@
{
"_from": "concatenate@0.0.2",
"_id": "concatenate@0.0.2",
"_inBundle": false,
"_integrity": "sha1-C0nW6MQQR9dyjNyNYqCGYjOXtJ8=",
"_location": "/concatenate",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "concatenate@0.0.2",
"name": "concatenate",
"escapedName": "concatenate",
"rawSpec": "0.0.2",
"saveSpec": null,
"fetchSpec": "0.0.2"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/concatenate/-/concatenate-0.0.2.tgz",
"_shasum": "0b49d6e8c41047d7728cdc8d62a086623397b49f",
"_spec": "concatenate@0.0.2",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\laravel-mix",
"author": {
"name": "Stephen Mathieson",
"email": "me@stephenmathieson.com"
},
"bugs": {
"url": "https://github.com/stephenmathieson/node-concatenate/issues"
},
"bundleDependencies": false,
"dependencies": {
"globs": "^0.1.2"
},
"deprecated": false,
"description": "concatenate files",
"devDependencies": {
"jshint": "1.0.0",
"mocha": "latest",
"rimraf": "latest",
"should": "latest"
},
"homepage": "https://github.com/stephenmathieson/node-concatenate#readme",
"keywords": [],
"main": "index",
"name": "concatenate",
"repository": {
"type": "git",
"url": "git://github.com/stephenmathieson/node-concatenate.git"
},
"version": "0.0.2"
}

View File

@@ -0,0 +1,45 @@
# node-concatenate
Easily concatenate files
## API
### `concatenate(files, cb)`
Parameters:
- `files` A list of files or file patterns to concatenate
- `cb` Either a callback function or a file path to synchronously write to
### `concatenate.sync(files, [out])`
Parameters:
- `files` A list of files or file patterns to concatenate
- `out` An optional file path to synchronously write to
## License
(The MIT License)
Copyright (c) 2012 Stephen Mathieson &lt;me@stephenmathieson.com&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.