diff --git a/LICENSE-MIT b/LICENSE-MIT index 6123def..0672773 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) Rafael Xavier de Souza http://rafael.xavier.blog.br +Copyright OpenJS Foundation and other contributors, https://openjsf.org/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index c276a47..87dbbe9 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,4 @@ structure. ## License -MIT © [Rafael Xavier de Souza](http://rafael.xavier.blog.br) +MIT © [OpenJS Foundation and other contributors](https://openjsf.org/) diff --git a/index.js b/index.js index 66aab5c..de910d8 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ function cssDependencies( data, which ) { regexp = new RegExp( "\\/\\/>>\\s*css\\." + which + ":(.*)", "g" ); data.replace( regexp, function( garbage, input ) { - input = input.split( "," ).map( trim ); + input = input.split( "," ).map( trim ); result.push.apply( result, input ); }); @@ -15,15 +15,11 @@ function cssDependencies( data, which ) { } function jsDependencies( data ) { - var match, - result = []; - - match = data.match( /define\(\[([^\]]*?)\]/ ); - if ( match !== null ) { - result = match[ 1 ].split( "," ).map( trim ); + var match = data.match( /define\(\ ?\[([^\]]*?)\]/ ); + if ( match === null ) { + return []; } - - return result; + return match[ 1 ].replace( /\/\/.+/g, "" ).split( "," ).map( trim ); } /** diff --git a/package.json b/package.json index 238c7ac..829939d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "builder-jquery-css", - "version": "0.0.2", + "version": "0.0.4", "main": "index.js", "repository": { "type": "git", diff --git a/test/fixtures/basic/foo.js b/test/fixtures/basic/foo.js index 52736fc..7052c3c 100644 --- a/test/fixtures/basic/foo.js +++ b/test/fixtures/basic/foo.js @@ -1,2 +1,6 @@ //>> css.baz: ./foo.css -define([ "./bar" ]); +define([ + + // comment + "./bar" +]); diff --git a/test/fixtures/nested/theme/input.css b/test/fixtures/nested/theme/input.css new file mode 100644 index 0000000..c4236fe --- /dev/null +++ b/test/fixtures/nested/theme/input.css @@ -0,0 +1 @@ +input {} diff --git a/test/fixtures/nested/theme/version.css b/test/fixtures/nested/theme/version.css new file mode 100644 index 0000000..208d16d --- /dev/null +++ b/test/fixtures/nested/theme/version.css @@ -0,0 +1 @@ +body {} diff --git a/test/fixtures/nested/version.js b/test/fixtures/nested/version.js new file mode 100644 index 0000000..3af1221 --- /dev/null +++ b/test/fixtures/nested/version.js @@ -0,0 +1,2 @@ +//>> css.structure: ./theme/version.css +define( "0.2.0" ); diff --git a/test/fixtures/nested/widgets/input.js b/test/fixtures/nested/widgets/input.js new file mode 100644 index 0000000..d3ca601 --- /dev/null +++ b/test/fixtures/nested/widgets/input.js @@ -0,0 +1,3 @@ +//>> css.structure: ../theme/input.css +define( ["../version"], function( version ) { +} ); diff --git a/test/index.js b/test/index.js index bf1e0d0..82bed37 100644 --- a/test/index.js +++ b/test/index.js @@ -49,6 +49,28 @@ describe( "jQuery CSS Builder", function() { }); + describe( "Basic - nested+appdir", function() { + var css, + files = { + "fixtures/version.js": fs.readFileSync( __dirname + "/fixtures/nested/version.js" ), + "fixtures/widgets/input.js": fs.readFileSync( __dirname + "/fixtures/nested/widgets/input.js" ), + "fixtures/theme/version.css": fs.readFileSync( __dirname + "/fixtures/nested/theme/version.css" ), + "fixtures/theme/input.css": fs.readFileSync( __dirname + "/fixtures/nested/theme/input.css" ) + }; + + before(function( done ) { + jQueryCSSBuilder( files, "structure", { appDir: "fixtures", include: [ "widgets/input" ] }, function( error, _css ) { + css = _css; + done( error ); + }); + }); + + it( "should build just fine", function() { + expect( css ).to.equal( "input {}\nbody {}\n" ); + }); + + }); + describe( "Two bundles", function() { var cssNorth, cssSouth; var files = {