forked from jbernoudy/cordova-docs
-
Notifications
You must be signed in to change notification settings - Fork 4
/
hook-execute-bit-fix.js
40 lines (35 loc) · 1.35 KB
/
hook-execute-bit-fix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Copyright (c) Microsoft. All rights reserved.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
var fs = require("fs");
var path = require("path");
var exec = require("child_process").exec;
var Q;
module.exports = function(context) {
// Only bother if we're on OSX and are after platform add for iOS itself (still need to run for other platforms)
if(process.platform =="darwin" &&
context.opts &&
context.opts.cordova &&
context.opts.cordova.platforms &&
!(context.hook == "before_platform_add" && context.opts.platforms.indexOf("ios") >= 0)) {
console.log("here")
// Grab the Q, glob node modules from cordova
Q=context.requireCordovaModule("q");
// Need to return a promise since glob is async
var deferred = Q.defer();
// Generate the script to set execute bits for installed platforms
var script ="";
context.opts.cordova.platforms.forEach(function(platform) {
script += "find -E platforms/" + platform + "/cordova -type f -regex \"[^.(LICENSE)]*\" -exec chmod +x {} +\n"
});
// Run script
exec(script, function(err, stderr, stdout) {
if(err) deferred.reject(err);
if(stderr) console.error(stderr);
if(stdout) console.log(stdout);
deferred.resolve();
});
return deferred.promise;
}
}