sectionify

0.1.2 • Public • Published

sectionify.js

A CLI for building API-specific versions of single-file JS libraries

Installation

npm install sectionify

Usage

sectionify [--header=msg] input_file [dependencies]

In your code, mark sections and dependencies with //SECTION comments:

E.g. In sample.js:

var a = 'leading code is always included';
//SECTION foo
function hello(msg) {console.log('hello ' + msg);}
//SECTION bar REQUIRE foo
hello('do bar things');
//SECTION baz REQUIRE foo
hello('do baz things');
//SECTION
var b = 'trailing code is always included';

Then build section-specific scripts with sectionify. Only the required sections are kept:

> sectionify sample.js foo

var a = 'leading code is always included';
function hello(msg) {console.log('hello ' + msg);}
var b = 'trailing code is always included';

REQUIREed sections get included for you:

> sectionify sample.js narf

var a = 'leading code is always included';
function hello(msg) {console.log('hello ' + msg);}
hello('do bar things');
hello('do baz things');
hello('do narf things');
var b = 'trailing code is always included';

Build with multiple sections:

> sectionify sample.js bar baz

var a = 'leading code is always included';
function hello(msg) {console.log('hello ' + msg);}
hello('do bar things');
hello('do baz things');
var b = 'trailing code is always included';

Prepend a header string to the output:

> sectionify --header='// AUTO-GENERATED - DO NOT EDIT\n' sample.js

// AUTO-GENERATED - DO NOT EDIT
var a = 'leading code is always included';
var b = 'trailing code is always included';

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    0
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i sectionify

Weekly Downloads

0

Version

0.1.2

License

none

Last publish

Collaborators

  • broofa