Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for pugjs (previously known as jade) #239

Merged
merged 1 commit into from
Jun 7, 2016
Merged
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
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