Skip to content

Commit

Permalink
added support for pugjs (previously known as jade)
Browse files Browse the repository at this point in the history
  • Loading branch information
greyfocus committed Apr 20, 2016
1 parent 3416e1e commit 50104b4
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/default-file-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ module.exports = {
}
},

pug: {
block: /(([ \t]*)\/\/-?\s*bower:*(\S*))(\n|\r|.)*?(\/\/-?\s*endbower)/gi,
detect: {
js: /script\(.*src=['"]([^'"]+)/gi,
css: /link\(.*href=['"]([^'"]+)/gi
},
replace: {
js: 'script(src=\'{{filePath}}\')',
css: 'link(rel=\'stylesheet\', href=\'{{filePath}}\')'
}
},

slim: {
block: /(([ \t]*)\/!?\s*bower:(\S*))(\n|\r|.)*?(\/!?\s*endbower)/gi,
detect: {
Expand Down
10 changes: 10 additions & 0 deletions test/fixture/pug/index-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
// endbower
body
// bower:js
// endbower
10 changes: 10 additions & 0 deletions test/fixture/pug/index-after-uninstall-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
// endbower
body
// bower:js
// endbower
13 changes: 13 additions & 0 deletions test/fixture/pug/index-after-uninstall-all-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
10 changes: 10 additions & 0 deletions test/fixture/pug/index-after-uninstall-all-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
// endbower
body
// bower:js
// endbower
13 changes: 13 additions & 0 deletions test/fixture/pug/index-after-uninstall-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
10 changes: 10 additions & 0 deletions test/fixture/pug/index-custom-format-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
// endbower
body
// bower:js
// endbower
15 changes: 15 additions & 0 deletions test/fixture/pug/index-custom-format-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(href='../bower_components/codecode/dist/codecode.css', rel='stylesheet')
link(href='../bower_components/bootstrap/dist/css/bootstrap.css', rel='stylesheet')
// endbower
body
// bower:js
script(type='text/javascript', src='../bower_components/jquery/jquery.js')
script(type='text/javascript', src='../bower_components/codecode/dist/codecode.js')
script(type='text/javascript', src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
10 changes: 10 additions & 0 deletions test/fixture/pug/index-excluded-files-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
// endbower
body
// bower:js
// endbower
12 changes: 12 additions & 0 deletions test/fixture/pug/index-excluded-files-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
// endbower
15 changes: 15 additions & 0 deletions test/fixture/pug/index-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/codecode/dist/codecode.css')
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/codecode/dist/codecode.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
15 changes: 15 additions & 0 deletions test/fixture/pug/index-second-run-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/codecode/dist/codecode.css')
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/codecode/dist/codecode.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
15 changes: 15 additions & 0 deletions test/fixture/pug/index-second-run-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
// bower:css
link(rel='stylesheet', href='../bower_components/codecode/dist/codecode.css')
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
// endbower
body
// bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/codecode/dist/codecode.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
// endbower
10 changes: 10 additions & 0 deletions test/fixture/pug/index-unbuffered-comments-actual.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
//- bower:css
//- endbower
body
//- bower:js
//- endbower
15 changes: 15 additions & 0 deletions test/fixture/pug/index-unbuffered-comments-expected.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
title test.
//- bower:css
link(rel='stylesheet', href='../bower_components/codecode/dist/codecode.css')
link(rel='stylesheet', href='../bower_components/bootstrap/dist/css/bootstrap.css')
//- endbower
body
//- bower:js
script(src='../bower_components/jquery/jquery.js')
script(src='../bower_components/codecode/dist/codecode.js')
script(src='../bower_components/bootstrap/dist/js/bootstrap.js')
//- endbower
9 changes: 9 additions & 0 deletions test/wiredep_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ describe('wiredep', function () {
assert.equal(filePaths.read('expected'), filePaths.read('actual'));
});

it('should work with pug files (buffered comments)', testReplace('pug'));

it('should work with pug files (unbuffered comments)', function () {
var filePaths = getFilePaths('index-unbuffered-comments', 'pug');

wiredep({ src: [filePaths.actual] });

assert.equal(filePaths.read('expected'), filePaths.read('actual'));
});
it('should work with sass files', testReplace('sass'));
it('should work with scss files', testReplace('scss'));
it('should work with yml files', testReplace('yml'));
Expand Down

0 comments on commit 50104b4

Please sign in to comment.