ncat
Node CLI to concatenate multiple files, with their sourcemaps and optionally stdin, a banner and a footer
Last updated 2 months ago by pvdlg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ncat 
SYNC missed versions from official npm registry.

ncat

Node CLI to concatenate multiple files, with their sourcemaps and optionally stdin, a banner and a footer.

Travis AppVeyor Codecov Greenkeeper badge license

Installation

$ npm i -g|-D ncat

Usage

$ ncat [<FILES ...>] [OPTIONS] [-o|--output <OUTPUT_FILE>]

The arguments may be a list of files:

$ ncat file_1.js file_2.js -o dist/bundle.js

or a list of globs:

$ ncat 'src/**/*.js !**/rainbow.js' src/**/{cake,unicorn}.css -o dist/bundle.js

If file is a single dash (-) ncat reads from the standard input:

$ echo 'Insert between file_1.js and file_2.js' | ncat file_1.js - file_2.js -o dist/bundle.js

If -o|--output is omitted ncat writes to the standard input:

$ ncat file_1.js file_2.js | uglifyjs > dist/bundle.min.js

Options

Name Type Default Description
-o, --output {String} undefined Output File
-m, --map {Boolean} false Create an external sourcemap (including the sourcemaps of existing files)
-e, --map-embed {Boolean} false Embed the code in the sourcemap (only apply to code without an existing sourcemap)
-b, --banner {Boolean\|String} false Add a banner built with the package.json file. Optionally pass the path to a .js file containing custom banner that can be called with require()
-f, --footer {String} undefined The path to .js file containing custom footer that can be called with require()
-h, --help {Boolean} false CLI Help
-v, --version {Boolean} false CLI Version

Examples

Concatenate files and standard input

Files

---------- file_1.min.js ----------
< First part of JS code (minified) ... >

---------- file_2.js ----------
<Second part of JS code ... >

Command

$ uglifyjs file_2.js | ncat file_1.min.js - --output dist/bundle.js

Result

---------- dist/bundle.js ----------
< First part of JS code (minified) ... >

< Second part of JS code (minified) ... >

Concatenate with sourcemaps

Files

---------- file_1.js ----------
< First part of JS code ... >

/*# sourceMappingURL=file_1.js.map */

---------- file_1.js.map ----------
{"version": 3,"file": "file_1.js", ... }

---------- file_2.js ----------
< Second part of JS code ... >

/*# sourceMappingURL=file_2.js.map */

---------- file_2.js.map ----------
{"version": 3,"file": "file_2.js", ... }

Command

$ ncat file_1.js file_2.js --map --output dist/bundle.js

Result

---------- dist/bundle.js ----------
< First part of JS code ... >

< Second part of JS code ... >

/*# sourceMappingURL=bundle.map */

---------- bundle.js.map ----------
{"version": 3,"file": "bundle.js", ... }

Add a banner to a file

Files

---------- bootstrap.js ----------
< JS code ... >

Command

$ ncat bootstrap.js --banner --output dist/bundle.js

Result

---------- dist/bundle.js ----------
/*!
 * Bootstrap v4.0.0
 * https://getbootstrap.com
 *
 * Copyright 2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
 * Licensed under MIT license
 */

< JS code ... >

Add a custom banner and footer to a file

Files

---------- bootstrap.js ----------
< JS code ... >

---------- build/banner.js ----------
const pkg = require('read-pkg-up').sync().pkg;
module.exports =
`/*!
 * ${pkg.name} v${pkg.version} (${pkg.homepage})
 *
 * Copyright (c) 2011-${new Date().getFullYear()} ${pkg.author.name}
 * Licensed under the ${pkg.license} license */

(function () {`;

---------- build/footer.js ----------
module.exports = `
})()`

Command

$ ncat bootstrap.js --banner build/banner.js --footer build/footer.js --output dist/bundle.js

Result

---------- dist/bundle.js ----------
/*!
 * Bootstrap v4.0.0 (https://getbootstrap.com)
 *
 * Copyright (c) 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
 * Licensed under the MIT license */

(function () {
< JS code ... >
})()

Current Tags

  • 4.0.2                                ...           latest (2 months ago)

28 Versions

  • 4.0.2                                ...           2 months ago
  • 4.0.1                                ...           4 months ago
  • 4.0.0                                ...           4 months ago
  • 3.0.2                                ...           6 months ago
  • 3.0.1                                ...           7 months ago
  • 3.0.0                                ...           7 months ago
  • 2.0.9                                ...           8 months ago
  • 2.0.8                                ...           8 months ago
  • 2.0.7                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.8                                ...           2 years ago
  • 1.1.7                                ...           2 years ago
  • 1.1.6                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 30
Dependencies (11)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |