| <p>This is some HTML above the inserted HTML.</p> | ||
| <p>This is the included content.</p> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>This is some HTML above the inserted HTML.</p> | ||
| <p>This is the included content.</p> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>this is the content of input.html and should be on the second line</p> | ||
| <p>this is the one and only line in depends-one.html</p> | ||
| <p>this is the one and only line in depends-two.html</p> | ||
| <p>this is the last line of input.html</p> |
| <p>This is some HTML above the inserted HTML.</p> | ||
| <p>This is the included content.</p> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>This is some HTML above the inserted HTML.</p> | ||
| <p>This is the included content.</p> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>this is the content of input.html and should be on the second line</p> | ||
| <p>this is the one and only line in depends-one.html</p> | ||
| <p>this is the one and only line in depends-two.html</p> | ||
| <p>this is the last line of input.html</p> |
| <p>This is some HTML above the inserted HTML.</p> | ||
| <!-- @depends depends-one.html --> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>This is the included content.</p> |
| <p>This is some HTML above the inserted HTML.</p> | ||
| <!-- @import import-one.html --> | ||
| <p>This is some HTML below the inserted HTML.</p> |
| <p>This is the included content.</p> |
| <p>this is the one and only line in depends-one.html</p> |
| <p>this is the one and only line in depends-two.html</p> |
| <p>this is the content of input.html and should be on the second line</p> | ||
| <!-- @depends depends-one.html --> | ||
| <!-- @depends depends-two.html --> | ||
| <p>this is the last line of input.html</p> |
| // line one from basic-depends.js | ||
| // the only line from depends-one.js | ||
| // last line from basic-depends.js |
| // line one from basic-import.js | ||
| // the only line from import-one.js | ||
| // last line from basic-import.js |
| // this is the content of input.js and should be on the second line | ||
| // this is the one and only line in depends-one.js | ||
| // this is the one and only line in depends-two.js | ||
| // this is the last line of input.js |
| // line one from basic-depends.js | ||
| // the only line from depends-one.js | ||
| // last line from basic-depends.js |
| // line one from basic-import.js | ||
| // the only line from import-one.js | ||
| // last line from basic-import.js |
| var a = ( 1 || 2) | ||
| var b = a; | ||
| var a = 1; | ||
| var b = 2; |
| // this is the content of input.js and should be on the second line | ||
| // this is the one and only line in depends-one.js | ||
| // this is the one and only line in depends-two.js | ||
| // this is the last line of input.js |
| // line one from basic-depends.js | ||
| // @depends depends-one.js | ||
| // last line from basic-depends.js |
| // the only line from depends-one.js |
| // line one from basic-import.js | ||
| // @import import-one.js | ||
| // last line from basic-import.js |
| // the only line from import-one.js |
| var a = ( 1 || 2) | ||
| var b = a; | ||
| // @depends lintfree.js |
| var a = 1; | ||
| var b = 2; |
| /* this is a js file, that doesn't have any @depends directives */ | ||
| var a = 1; | ||
| var b = 2; | ||
| var c = a+b; |
| // this is the one and only line in depends-one.js |
| // this is the one and only line in depends-two.js |
| // this is the content of input.js and should be on the second line | ||
| // @depends depends-one.js | ||
| // @depends depends-two.js | ||
| // this is the last line of input.js |
+1
-1
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
| var _ = require('underscore'); | ||
| var argv = require('optimist').usage('Usage: $0 -i [javascript-file.js] -o [javascript-file.js] (-w) (-c) (-m) (-l)').demand(['i', 'o']).describe('i', 'JavaScript input file').describe('o', 'JavaScript output file').describe('w', 'Watch the input file for changes.').describe('c', 'Compress the output using UglifyJS2.').describe('m', 'Mangle the output using UglifyJS2.').describe('l', 'Lint the JavaScript using JSHint').argv; | ||
| var argv = require('optimist').usage('\nFuse JavaScript or HTML files.\n\nUsage: $0 -i [input-file.(js|html)] -o [output-file.(js|html)] (-w) (-c) (-m) (-l)').demand(['i', 'o']).describe('i', 'Input file').describe('o', 'Output file').describe('w', 'Watch the input file for changes.').describe('c', 'Compress the output using UglifyJS2 (JavaScript only).').describe('m', 'Mangle the output using UglifyJS2. (JavaScript only)').describe('l', 'Lint the JavaScript using JSHint (JavaScript only)').argv; | ||
| var fuse = require('../lib/fuse'); | ||
@@ -10,0 +10,0 @@ var path = require('path'); |
+12
-7
@@ -17,3 +17,4 @@ (function () { | ||
| // regular expression to find referenced files | ||
| fuse.re = /\/\/ ?@(?:depends|import) (.+)\b/gi; | ||
| fuse.re = fuse.reJS = /\/\/ ?@(?:depends|import) (.+)\b/gi; | ||
| fuse.reHTML = /<!--\s?@(?:depends|import)\s(.+?)\s?-->/gi; | ||
@@ -38,10 +39,14 @@ fuse.formatTime = function () { | ||
| // do we need to compress? | ||
| var compress = (arguments.length > 2) ? arguments[2] : false; | ||
| // do we need to mangle? | ||
| var mangle = (arguments.length > 3) ? arguments[3] : false; | ||
| // do we need to run the files through JSHint? | ||
| var lint = (arguments.length > 4) ? arguments[4] : false; | ||
| // what mode are we running in, HTML or JS? | ||
| var mode = path.extname(inputFile).replace(/^\./, ''); | ||
| // do we need to compress (js only)? | ||
| var compress = (arguments.length > 2) ? arguments[2] && mode === 'js' : false; | ||
| // do we need to mangle (js only)? | ||
| var mangle = (arguments.length > 3) ? arguments[3] && mode === 'js' : false; | ||
| // do we need to run the files through JSHint (js only)? | ||
| var lint = (arguments.length > 4) ? arguments[4] && mode === 'js' : false; | ||
| // exit will be true, if we're not watching files | ||
| var exit = (arguments.length === 6) ? arguments[5] : true; | ||
| // swtich the regular expression based on mode | ||
| this.re = (mode === 'js') ? this.reJS : this.reHTML; | ||
| // grab the content of the input file | ||
@@ -48,0 +53,0 @@ var content = fuse.getFileContent(inputFile); |
+2
-2
| { | ||
| "name" : "fuse", | ||
| "description" : "Command line combiner for fusing mutliple JavaScript files into one", | ||
| "description" : "Command line combiner for fusing mutliple JavaScript or HTML files into one.", | ||
| "url" : "http://github.com/smebberson/fuse", | ||
@@ -13,4 +13,4 @@ "keywords" : ["combiner", "javascript", "cli", "parser", "command", "packager"], | ||
| "directories" : { "bin": "./bin" }, | ||
| "version" : "0.1.1", | ||
| "version" : "0.2.0", | ||
| "engines" : {"node": ">=0.4"} | ||
| } |
+26
-14
@@ -1,8 +0,8 @@ | ||
| # Fuse [](https://travis-ci.org/smebberson/fuse) | ||
| # Fuse [![Build Status][image-1]][1] | ||
| > Fuse is a command line tool to fuse multiple JavaScript files into one, and optionally compress or mangle the JavaScript code. | ||
| > Fuse is a command line tool to fuse multiple JavaScript or HTML files into one. If you're fusing JavaScript you can optionally compress or mangle the JavaScript code. | ||
| ## Introduction | ||
| Fuse is a simple cli tool to combine multiple JavaScript files into one. It also makes use of UglifyJS2 to either compress, or mangle or do both to the output of the JavaScript. It's designed to be simple, do less and be easy to use. | ||
| Fuse is a simple cli tool to combine multiple JavaScript or HTML files into one. It also makes use of UglifyJS2 to either compress, or mangle or do both to the output of the JavaScript. It's designed to be simple, do less and be easy to use. | ||
@@ -19,3 +19,3 @@ ## Installation (via NPM) | ||
| Tests are run using [Mocha][mocha]. You can also run `make test` to run the tests. | ||
| Tests are run using [Mocha][2]. You can also run `make test` to run the tests. | ||
@@ -26,3 +26,3 @@ ## Usage | ||
| Fuse uses inline comment-based directives to determine which JavaScript files you'd like to determine. Use the following syntax in your main JavaScript file to inform Fuse about which JavaScript file you'd like to fuse and where. | ||
| Fuse uses inline comment-based directives to determine which JavaScript files you'd like to fuse. Use the following syntax in your main JavaScript file to inform Fuse about which JavaScript file you'd like to fuse and where. | ||
@@ -33,31 +33,43 @@ // @depends path/to/javascript/file.js | ||
| ### In your HTML file | ||
| Fuse uses HTML comment-based directives to determine which HTML files you'd like to fuse. Use the following syntax in your main HTML file to inform Fuse about which HTML file you'd like to fuse and where. | ||
| <!-- @depends path/to/html/file.html --> | ||
| Passing a file with the line above to Fuse, will produce a file containing the original HTML and the content of _path/to/html/file.html_ in the exact position of the depends statement. | ||
| ### On the command line | ||
| To run just once: | ||
| To run just once and combine JavaScript: | ||
| fuse -i path/to/main.js -o path/to/output.js | ||
| To watch a file for changes: | ||
| To watch a file for changes and combine HTML: | ||
| fuse -i path/to/main.js -o path/to/output.js -w | ||
| fuse -i path/to/main.html -o path/to/main-combined.html -w | ||
| When watching, Fuse will automatically watch any referenced files for changes too, and recompile the output file upon any changes to reference files. | ||
| To compress the output using UglifyJS2: | ||
| To compress the output using UglifyJS2 (JavaScript only): | ||
| fuse -i path/to/main.js -o path/to/output.js -c | ||
| To mangle the output using UglifyJS2: | ||
| To mangle the output using UglifyJS2 (JavaScript only): | ||
| fuse -i path/to/main.js -o path/to/output.js -m | ||
| To compress and mangle, and watch: | ||
| To compress and mangle, and watch (JavaScript only): | ||
| fuse -i path/to/main.js -o path/to/output.js -c -m -w | ||
| To lint with [jshint][jshint] before combining: | ||
| To lint with [jshint][3] before combining (JavaScript only): | ||
| fuse -i path/to/main.js -o path/to/output.js -l | ||
| [mocha]: http://visionmedia.github.com/mocha/ | ||
| [jshint]: http://www.jshint.com/about/ | ||
| [1]: https://travis-ci.org/smebberson/fuse | ||
| [2]: http://visionmedia.github.com/mocha/ | ||
| [3]: http://www.jshint.com/about/ | ||
| [image-1]: https://travis-ci.org/smebberson/fuse.png?branch=master |
+78
-20
@@ -8,28 +8,50 @@ var assert = require('assert'); | ||
| describe('should fuse two files', function () { | ||
| describe('with javascript', function () { | ||
| it('by @depends', function (done) { | ||
| describe('should fuse two files', function () { | ||
| exec('fuse -i ' + process.cwd() + '/test/src/depends/basic-depends.js -o ' + process.cwd() + '/test/result/depends/basic-depends-output.js', function (error, stdout, stderr) { | ||
| it('by @depends', function (done) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/result/depends/basic-depends-output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/expected/depends/basic-depends-result.js', 'utf-8')); | ||
| exec('fuse -i ' + process.cwd() + '/test/javascript/src/depends/basic-depends.js -o ' + process.cwd() + '/test/javascript/result/depends/basic-depends-output.js', function (error, stdout, stderr) { | ||
| // we're done | ||
| done(); | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/javascript/result/depends/basic-depends-output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/javascript/expected/depends/basic-depends-result.js', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
| it('by @import', function (done) { | ||
| exec('fuse -i ' + process.cwd() + '/test/javascript/src/import/basic-import.js -o ' + process.cwd() + '/test/javascript/result/import/basic-import-output.js', function (error, stdout, stderr) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/javascript/result/import/basic-import-output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/javascript/expected/import/basic-import-result.js', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| it('by @import', function (done) { | ||
| describe('should fuse multiple files', function () { | ||
| exec('fuse -i ' + process.cwd() + '/test/src/import/basic-import.js -o ' + process.cwd() + '/test/result/import/basic-import-output.js', function (error, stdout, stderr) { | ||
| it('with two depends', function (done) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/result/import/basic-import-output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/expected/import/basic-import-result.js', 'utf-8')); | ||
| exec('fuse -i ' + process.cwd() + '/test/javascript/src/twoDepends/input.js -o ' + process.cwd() + '/test/javascript/result/twoDepends/output.js', function (error, stdout, stderr) { | ||
| // we're done | ||
| done(); | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/javascript/result/twoDepends/output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/javascript/expected/twoDepends/result.js', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
@@ -41,20 +63,56 @@ | ||
| describe('should fuse multiple files', function () { | ||
| describe('with html', function () { | ||
| it('with two depends', function (done) { | ||
| describe('should fuse two files', function () { | ||
| exec('fuse -i ' + process.cwd() + '/test/src/twoDepends/input.js -o ' + process.cwd() + '/test/result/twoDepends/output.js', function (error, stdout, stderr) { | ||
| it('by <!-- @depends -->', function (done) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/result/twoDepends/output.js', 'utf-8'), fs.readFileSync(process.cwd() + '/test/expected/twoDepends/result.js', 'utf-8')); | ||
| exec('fuse -i ' + process.cwd() + '/test/html/src/depends/basic-depends.html -o ' + process.cwd() + '/test/html/result/depends/basic-depends-output.html', function (error, stdout, stderr) { | ||
| // we're done | ||
| done(); | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/html/result/depends/basic-depends-output.html', 'utf-8'), fs.readFileSync(process.cwd() + '/test/html/expected/depends/basic-depends-result.html', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
| it('by <!-- @import -->', function (done) { | ||
| exec('fuse -i ' + process.cwd() + '/test/html/src/import/basic-import.html -o ' + process.cwd() + '/test/html/result/import/basic-import-output.html', function (error, stdout, stderr) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/html/result/import/basic-import-output.html', 'utf-8'), fs.readFileSync(process.cwd() + '/test/html/expected/import/basic-import-result.html', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('should fuse multiple files', function () { | ||
| it('with two depends', function (done) { | ||
| exec('fuse -i ' + process.cwd() + '/test/html/src/twoDepends/input.html -o ' + process.cwd() + '/test/html/result/twoDepends/output.html', function (error, stdout, stderr) { | ||
| // check the output against the expected output | ||
| assert.equal(fs.readFileSync(process.cwd() + '/test/html/result/twoDepends/output.html', 'utf-8'), fs.readFileSync(process.cwd() + '/test/html/expected/twoDepends/result.html', 'utf-8')); | ||
| // we're done | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| // line one from basic-depends.js | ||
| // the only line from depends-one.js | ||
| // last line from basic-depends.js |
| // line one from basic-import.js | ||
| // the only line from import-one.js | ||
| // last line from basic-import.js |
| // this is the content of input.js and should be on the second line | ||
| // this is the one and only line in depends-one.js | ||
| // this is the one and only line in depends-two.js | ||
| // this is the last line of input.js |
| // line one from basic-depends.js | ||
| // the only line from depends-one.js | ||
| // last line from basic-depends.js |
| // line one from basic-import.js | ||
| // the only line from import-one.js | ||
| // last line from basic-import.js |
| var a = ( 1 || 2) | ||
| var b = a; | ||
| var a = 1; | ||
| var b = 2; |
| // this is the content of input.js and should be on the second line | ||
| // this is the one and only line in depends-one.js | ||
| // this is the one and only line in depends-two.js | ||
| // this is the last line of input.js |
| // line one from basic-depends.js | ||
| // @depends depends-one.js | ||
| // last line from basic-depends.js |
| // the only line from depends-one.js |
| // line one from basic-import.js | ||
| // @import import-one.js | ||
| // last line from basic-import.js |
| // the only line from import-one.js |
| var a = ( 1 || 2) | ||
| var b = a; | ||
| // @depends lintfree.js |
| var a = 1; | ||
| var b = 2; |
| /* this is a js file, that doesn't have any @depends directives */ | ||
| var a = 1; | ||
| var b = 2; | ||
| var c = a+b; |
| // this is the one and only line in depends-one.js |
| // this is the one and only line in depends-two.js |
| // this is the content of input.js and should be on the second line | ||
| // @depends depends-one.js | ||
| // @depends depends-two.js | ||
| // this is the last line of input.js |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
34070
16.21%39
50%776
5.01%72
18.03%