@@ -28,6 +28,7 @@ module.exports = function (grunt) {
28
28
var common = require ( "./common" ) ( grunt ) ,
29
29
fs = require ( "fs" ) ,
30
30
child_process = require ( "child_process" ) ,
31
+ path = require ( "path" ) ,
31
32
q = require ( "q" ) ,
32
33
/* win only (lib), mac only (Resources, tools) */
33
34
CEF_MAPPING = {
@@ -70,8 +71,8 @@ module.exports = function (grunt) {
70
71
grunt . registerTask ( "cef" , "Download and setup CEF" , function ( ) {
71
72
var config = "cef-" + platform + common . arch ( ) ,
72
73
zipSrc = grunt . config ( "curl-dir." + config + ".src" ) ,
73
- zipName = zipSrc . substr ( zipSrc . lastIndexOf ( "/" ) + 1 ) ,
74
- zipDest = grunt . config ( "curl-dir." + config + ".dest" ) + zipName ,
74
+ zipName = path . basename ( zipSrc ) ,
75
+ zipDest = path . resolve ( process . cwd ( ) , path . join ( grunt . config ( "curl-dir." + config + ".dest" ) , zipName ) ) ,
75
76
txtName ;
76
77
77
78
// extract zip file name and set config property
@@ -140,22 +141,29 @@ module.exports = function (grunt) {
140
141
unzipPromise = unzip ( zipDest , "deps" ) ;
141
142
142
143
// remove .zip ext
143
- zipName = zipName . substr ( 0 , zipName . lastIndexOf ( "." ) ) ;
144
+ zipName = path . basename ( zipName , ".zip" ) ;
144
145
145
146
unzipPromise . then ( function ( ) {
146
147
// rename version stamped name to cef
147
148
return rename ( "deps/" + zipName , "deps/cef" ) ;
148
149
} ) . then ( function ( ) {
150
+ var memo = path . resolve ( process . cwd ( ) , "deps/cef/" + zipName + ".txt" ) ,
151
+ permissionsPromise ,
152
+ defer = q . defer ( ) ;
153
+
149
154
if ( platform === "mac" ) {
150
155
// FIXME figure out how to use fs.chmod to only do additive mode u+x
151
- return exec ( "chmod u+x deps/cef/tools/*" ) ;
156
+ permissionsPromise = exec ( "chmod u+x deps/cef/tools/*" ) ;
157
+ } else {
158
+ permissionsPromise = q . resolve ( ) ;
152
159
}
153
160
154
- // write empty file with zip file
155
- grunt . file . write ( "deps/cef/" + zipName + ".txt" , "" ) ;
156
-
157
- // return a resolved promise
158
- return q . resolve ( ) ;
161
+ return permissionsPromise . then ( function ( ) {
162
+ // write empty file with zip file
163
+ grunt . file . write ( memo , "" ) ;
164
+
165
+ return q . resolve ( ) ;
166
+ } ) ;
159
167
} ) . then ( function ( ) {
160
168
done ( ) ;
161
169
} , function ( err ) {
@@ -208,7 +216,7 @@ module.exports = function (grunt) {
208
216
// curl-dir:node-win32 defines multiple downloads, account for this array
209
217
nodeSrc . forEach ( function ( value , index ) {
210
218
nodeSrc [ index ] = value . substr ( value . lastIndexOf ( "/" ) + 1 ) ;
211
- nodeDest [ index ] = dest + nodeSrc [ index ] ;
219
+ nodeDest [ index ] = path . join ( dest , nodeSrc [ index ] ) ;
212
220
213
221
missingDest = missingDest || ! grunt . file . exists ( nodeDest [ index ] ) ;
214
222
} ) ;
0 commit comments