Skip to content

Commit ce805f3

Browse files
committed
[cdt-168] - fix inplaced
1 parent c568fa8 commit ce805f3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/commands/minify.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export default class Minify extends Command {
3636
this.minifyString(flags, args)
3737
}
3838

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+
3947
// this will get file type either from flags.type or file extension ( if flag is not given)
4048
private getFileType(flags: any, args: any) {
4149
if (flags.type) //if type is given
@@ -82,22 +90,22 @@ export default class Minify extends Command {
8290

8391
//TODO: add image compression also
8492
//TODO: add error handling also
85-
private minifyString(flags: any, args: any) {
93+
private async minifyString(flags: any, args: any) {
8694
Logger.progressStart(this, 'minifying...')
8795

8896
let output = ''
8997
// setTimeout(() => { //TODO: can add spinner for bigger files using promise
9098
switch (flags.type) {
9199
case Minify.JS:
92-
output = MinifyJs.js(args.string); break
100+
output = await this.evalJs(args.string); break
93101
case Minify.CSS:
94102
output = MinifyJs.css(args.string); break
95103
case Minify.HTML:
96104
output = MinifyJs.html(args.string); break
97105
default:
98106
Logger.error(this, 'Invalid Minifier Type')
99107
}
100-
Logger.progressStop(this, `file: ${flags.file} minified`)
108+
Logger.progressStop(this, `file: ${args.file} minified`)
101109
// }, 1000)
102110

103111
if (flags.output) { // if output path is provided then write to file also

0 commit comments

Comments
 (0)