File tree 3 files changed +32
-22
lines changed
3 files changed +32
-22
lines changed Original file line number Diff line number Diff line change
1
+ var path = require ( 'path' ) ;
2
+
3
+ var transformTools = require ( 'browserify-transform-tools' ) ;
4
+
5
+ var constants = require ( './constants' ) ;
6
+
7
+ /**
8
+ * Transform require paths starting with '@' to appropriate folder paths
9
+ */
10
+
11
+ var shortcutsConfig = {
12
+ '@src' : constants . pathToSrc ,
13
+ '@mocks' : constants . pathToMocks
14
+ } ;
15
+
16
+ module . exports = transformTools . makeRequireTransform ( 'requireTransform' ,
17
+ { evaluateArguments : true , jsFilesOnly : true } ,
18
+ function ( args , opts , cb ) {
19
+ var pathIn = args [ 0 ] ;
20
+ var pathOut ;
21
+
22
+ Object . keys ( shortcutsConfig ) . forEach ( function ( k ) {
23
+ if ( pathIn . indexOf ( k ) !== - 1 ) {
24
+ var tail = pathIn . split ( k ) [ 1 ] ;
25
+ pathOut = 'require(\'' + shortcutsConfig [ k ] + tail + '\')' ;
26
+ }
27
+ } ) ;
28
+
29
+ if ( pathOut ) return cb ( null , pathOut ) ;
30
+ else return cb ( ) ;
31
+ } ) ;
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ func.defaultConfig = {
57
57
singleRun : false ,
58
58
59
59
browserify : {
60
- transform : [ './transform .js' ] ,
60
+ transform : [ '../../tasks/util/shortcut_paths .js' ] ,
61
61
extensions : [ '.js' ] ,
62
62
watch : true ,
63
63
debug : true
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments