File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
test/scripts/theme_processors Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 33var Pattern = require ( 'hexo-util' ) . Pattern ;
44var common = require ( '../../plugins/processor/common' ) ;
55
6+ function startsWith ( str , prefix ) {
7+ return str . substring ( 0 , prefix . length ) === prefix ;
8+ }
9+
610exports . process = function ( file ) {
711 var Asset = this . model ( 'Asset' ) ;
812 var id = file . source . substring ( this . base_dir . length ) . replace ( / \\ / g, '/' ) ;
@@ -27,10 +31,10 @@ exports.process = function(file) {
2731} ;
2832
2933exports . pattern = new Pattern ( function ( path ) {
30- if ( path . substring ( 0 , 7 ) !== 'source/' ) return false ;
34+ if ( ! startsWith ( path , 'source/' ) ) return false ;
3135
3236 path = path . substring ( 7 ) ;
33- if ( common . isHiddenFile ( path ) || common . isTmpFile ( path ) ) return false ;
37+ if ( common . isHiddenFile ( path ) || common . isTmpFile ( path ) || ~ path . indexOf ( 'node_modules' ) ) return false ;
3438
3539 return { path : path } ;
3640} ) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ describe('source', function() {
4646 pattern . match ( 'source/foo.jpg%' ) . should . be . false ;
4747 pattern . match ( 'layout/foo.swig' ) . should . be . false ;
4848 pattern . match ( 'package.json' ) . should . be . false ;
49+ pattern . match ( 'node_modules/test/test.js' ) . should . be . false ;
50+ pattern . match ( 'source/node_modules/test/test.js' ) . should . be . false ;
4951 } ) ;
5052
5153 it ( 'type: create' , function ( ) {
You can’t perform that action at this time.
0 commit comments