@@ -51,7 +51,9 @@ exports.minifyJS = function(req, res, jsFilename)
51
51
} else {
52
52
throw new Error ( "there is no profile for creating " + name ) ;
53
53
}
54
-
54
+
55
+ var rootPath = path . normalize ( __dirname + "/../../" ) ;
56
+
55
57
//minifying is enabled
56
58
if ( settings . minify )
57
59
{
@@ -63,7 +65,7 @@ exports.minifyJS = function(req, res, jsFilename)
63
65
//find out the highest modification date
64
66
function ( callback )
65
67
{
66
- var folders2check = [ "../ static/css", "../ static/js"] ;
68
+ var folders2check = [ rootPath + " static/css", rootPath + " static/js"] ;
67
69
68
70
//go trough this two folders
69
71
async . forEach ( folders2check , function ( path , callback )
@@ -102,7 +104,7 @@ exports.minifyJS = function(req, res, jsFilename)
102
104
function ( callback )
103
105
{
104
106
//check the modification time of the minified js
105
- fs . stat ( "../ var/minified_" + jsFilename , function ( err , stats )
107
+ fs . stat ( rootPath + " var/minified_" + jsFilename , function ( err , stats )
106
108
{
107
109
if ( err && err . code != "ENOENT" )
108
110
{
@@ -127,7 +129,7 @@ exports.minifyJS = function(req, res, jsFilename)
127
129
{
128
130
async . forEach ( jsFiles , function ( item , callback )
129
131
{
130
- fs . readFile ( "../ static/js/" + item , "utf-8" , function ( err , data )
132
+ fs . readFile ( rootPath + " static/js/" + item , "utf-8" , function ( err , data )
131
133
{
132
134
if ( ERR ( err , callback ) ) return ;
133
135
fileValues [ item ] = data ;
@@ -205,7 +207,7 @@ exports.minifyJS = function(req, res, jsFilename)
205
207
//write the results plain in a file
206
208
function ( callback )
207
209
{
208
- fs . writeFile ( "../ var/minified_" + jsFilename , result , "utf8" , callback ) ;
210
+ fs . writeFile ( rootPath + " var/minified_" + jsFilename , result , "utf8" , callback ) ;
209
211
} ,
210
212
//write the results compressed in a file
211
213
function ( callback )
@@ -219,7 +221,7 @@ exports.minifyJS = function(req, res, jsFilename)
219
221
220
222
if ( ERR ( err , callback ) ) return ;
221
223
222
- fs . writeFile ( "../ var/minified_" + jsFilename + ".gz" , compressedResult , callback ) ;
224
+ fs . writeFile ( rootPath + " var/minified_" + jsFilename + ".gz" , compressedResult , callback ) ;
223
225
} ) ;
224
226
}
225
227
//skip this step on windows
@@ -243,12 +245,12 @@ exports.minifyJS = function(req, res, jsFilename)
243
245
var pathStr ;
244
246
if ( gzipSupport && os . type ( ) . indexOf ( "Windows" ) == - 1 )
245
247
{
246
- pathStr = path . normalize ( __dirname + "/../../ var/minified_" + jsFilename + ".gz" ) ;
248
+ pathStr = path . normalize ( rootPath + "var/minified_" + jsFilename + ".gz" ) ;
247
249
res . header ( 'Content-Encoding' , 'gzip' ) ;
248
250
}
249
251
else
250
252
{
251
- pathStr = path . normalize ( __dirname + "/../../ var/minified_" + jsFilename ) ;
253
+ pathStr = path . normalize ( rootPath + "var/minified_" + jsFilename ) ;
252
254
}
253
255
254
256
res . sendfile ( pathStr , { maxAge : server . maxAge } ) ;
@@ -262,7 +264,7 @@ exports.minifyJS = function(req, res, jsFilename)
262
264
//read all js files
263
265
async . forEach ( jsFiles , function ( item , callback )
264
266
{
265
- fs . readFile ( "../ static/js/" + item , "utf-8" , function ( err , data )
267
+ fs . readFile ( rootPath + " static/js/" + item , "utf-8" , function ( err , data )
266
268
{
267
269
if ( ERR ( err , callback ) ) return ;
268
270
fileValues [ item ] = data ;
0 commit comments