File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -37,16 +37,30 @@ module.exports = class SpikeUtils {
3737 /**
3838 * Given a source file path, returns the path to the final output.
3939 * @param {String } file - path to source file
40+ * @param {String } extension - (optinal) final file extension
4041 * @return {File } object containing relative and absolute paths
4142 */
42- getOutputPath ( f ) {
43+ getOutputPath ( f , extension ) {
4344 let file = new File ( this . conf . context , f )
4445
4546 this . conf . spike . dumpDirs . forEach ( ( d ) => {
4647 const re = new RegExp ( `^${ d } \\${ path . sep } ` )
47- if ( file . relative . match ( re ) ) {
48- file = new File ( this . conf . output . path , file . relative . replace ( re , '' ) )
49- }
48+ if ( ! file . relative . match ( re ) )
49+ return
50+
51+ let output = file . relative . replace ( re , '' )
52+
53+ if ( ! extension )
54+ for ( let ext in this . conf . spike . matchers )
55+ if ( micromatch . isMatch ( output , this . conf . spike . matchers [ ext ] ) ) {
56+ extension = ext
57+ break
58+ }
59+
60+ if ( extension )
61+ output = output . replace ( path . extname ( output ) , '.' + extension )
62+
63+ file = new File ( this . conf . output . path , output )
5064 } )
5165
5266 return file
You can’t perform that action at this time.
0 commit comments