@@ -36,6 +36,14 @@ export default class Minify extends Command {
36
36
this . minifyString ( flags , args )
37
37
}
38
38
39
+ private async evalJs ( args : string ) {
40
+ let output = ''
41
+ await MinifyJs . js ( args )
42
+ . then ( ( val : string ) => output = val ) // cdt-168, Minify upgrade not return Promise Object for JS
43
+
44
+ return output
45
+ }
46
+
39
47
// this will get file type either from flags.type or file extension ( if flag is not given)
40
48
private getFileType ( flags : any , args : any ) {
41
49
if ( flags . type ) //if type is given
@@ -82,22 +90,22 @@ export default class Minify extends Command {
82
90
83
91
//TODO: add image compression also
84
92
//TODO: add error handling also
85
- private minifyString ( flags : any , args : any ) {
93
+ private async minifyString ( flags : any , args : any ) {
86
94
Logger . progressStart ( this , 'minifying...' )
87
95
88
96
let output = ''
89
97
// setTimeout(() => { //TODO: can add spinner for bigger files using promise
90
98
switch ( flags . type ) {
91
99
case Minify . JS :
92
- output = MinifyJs . js ( args . string ) ; break
100
+ output = await this . evalJs ( args . string ) ; break
93
101
case Minify . CSS :
94
102
output = MinifyJs . css ( args . string ) ; break
95
103
case Minify . HTML :
96
104
output = MinifyJs . html ( args . string ) ; break
97
105
default :
98
106
Logger . error ( this , 'Invalid Minifier Type' )
99
107
}
100
- Logger . progressStop ( this , `file: ${ flags . file } minified` )
108
+ Logger . progressStop ( this , `file: ${ args . file } minified` )
101
109
// }, 1000)
102
110
103
111
if ( flags . output ) { // if output path is provided then write to file also
0 commit comments