Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
});

Expand All @@ -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 );
}

/**
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/basic/foo.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
//>> css.baz: ./foo.css
define([ "./bar" ]);
define([

// comment
"./bar"
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind, you're testing for comments there. Alright.

1 change: 1 addition & 0 deletions test/fixtures/nested/theme/input.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input {}
1 change: 1 addition & 0 deletions test/fixtures/nested/theme/version.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body {}
2 changes: 2 additions & 0 deletions test/fixtures/nested/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//>> css.structure: ./theme/version.css
define("0.2.0");
3 changes: 3 additions & 0 deletions test/fixtures/nested/widgets/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//>> css.structure: ../theme/input.css
define(["../version"], function(version) {
});
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes as-is, but I don't think it should. Since input.js depends on version.js, their respective CSS should reflect that dependency, so this expect should be equal to "body {}\ninput {}\n"

@arschmitz @rxaviers thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've discussed this with @arschmitz and filed #2 to address this later. This PR should be good to land.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

});

});

describe( "Two bundles", function() {
var cssNorth, cssSouth;
var files = {
Expand Down