File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -37,16 +37,32 @@ module.exports = class SpikeUtils {
37
37
/**
38
38
* Given a source file path, returns the path to the final output.
39
39
* @param {String } file - path to source file
40
+ * @param {String } extension - (optinal) final file extension
40
41
* @return {File } object containing relative and absolute paths
41
42
*/
42
- getOutputPath ( f ) {
43
+ getOutputPath ( f , extension ) {
43
44
let file = new File ( this . conf . context , f )
44
45
45
46
this . conf . spike . dumpDirs . forEach ( ( d ) => {
46
47
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 , '' ) )
48
+ if ( ! file . relative . match ( re ) ) return
49
+
50
+ let output = file . relative . replace ( re , '' )
51
+
52
+ if ( ! extension ) {
53
+ for ( let ext in this . conf . spike . matchers ) {
54
+ if ( micromatch . isMatch ( output , this . conf . spike . matchers [ ext ] ) ) {
55
+ extension = ext
56
+ break
57
+ }
58
+ }
49
59
}
60
+
61
+ if ( extension ) {
62
+ output = output . replace ( path . extname ( output ) , '.' + extension )
63
+ }
64
+
65
+ file = new File ( this . conf . output . path , output )
50
66
} )
51
67
52
68
return file
You can’t perform that action at this time.
0 commit comments