├── LICENSE ├── README.md ├── index.js └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dominic Tarr 2 | 3 | Permission is hereby granted, free of charge, 4 | to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to 6 | deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, 8 | merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 20 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # indexhtmlify 2 | 3 | Wrap a js bundle in the minimum html to be browser runnable 4 | 5 | ``` 6 | # bundle and wrap 7 | browserify client.js | indexhtmlify > index.html 8 | 9 | # open in browser 10 | open index.html 11 | ``` 12 | 13 | # add metadata tags 14 | 15 | use [metadataify](https://github.com/rreusser/metadataify) 16 | 17 | ``` js 18 | browserify client.js | indexhtmlify | metadataify --title "title foo bar" 19 | ``` 20 | 21 | ## License 22 | 23 | MIT 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var opts = require('optimist').argv 4 | var through = require('through2'); 5 | 6 | function indexhtmlify(opts) { 7 | opts = opts || {} 8 | 9 | var s = through(function onwrite(chunk, enc, cb) { 10 | s.push(chunk) 11 | cb() 12 | }, function onend(cb) { 13 | s.push('\n') 14 | s.push('\n') 15 | cb() 16 | }) 17 | 18 | s.push('\n') 19 | if(opts.appcache) { 20 | var appcache = opts.appcache === true ? './manifest.appcache' : opts.appcache 21 | s.push('') 22 | } 23 | else 24 | s.push('\n') 25 | s.push('\n') 26 | s.push('' + (opts.title || '---') + '\n') 27 | s.push('\n') 29 | s.push('\n') 30 | 31 | if (opts.style) { 32 | s.push('\n') 35 | } 36 | 37 | s.push('\n') 38 | s.push('