apache / cordova-osx
Showing 5 of 30 files from the diff.

@@ -15,20 +15,20 @@
Loading
15 15
       under the License.
16 16
*/
17 17
18 -
var fs = require('fs');
19 -
var path = require('path');
20 -
var shell = require('shelljs');
21 -
var events = require('cordova-common').events;
22 -
var CordovaError = require('cordova-common').CordovaError;
18 +
const fs = require('fs');
19 +
const path = require('path');
20 +
const shell = require('shelljs');
21 +
const events = require('cordova-common').events;
22 +
const CordovaError = require('cordova-common').CordovaError;
23 23
24 24
// These frameworks are required by cordova-osx by default. We should never add/remove them.
25 -
var keep_these_frameworks = [
25 +
const keep_these_frameworks = [
26 26
    'MobileCoreServices.framework',
27 27
    'CoreGraphics.framework',
28 28
    'AssetsLibrary.framework'
29 29
];
30 30
31 -
var handlers = {
31 +
const handlers = {
32 32
    'source-file': {
33 33
        install: function (obj, plugin, project, options) {
34 34
            installHelper('source-file', obj, plugin.dir, project.projectDir, plugin.id, options, project);
@@ -47,25 +47,25 @@
Loading
47 47
    },
48 48
    'resource-file': {
49 49
        install: function (obj, plugin, project, options) {
50 -
            var src = obj.src;
51 -
            var srcFile = path.resolve(plugin.dir, src);
52 -
            var destFile = path.resolve(project.resources_dir, path.basename(src));
50 +
            const src = obj.src;
51 +
            const srcFile = path.resolve(plugin.dir, src);
52 +
            const destFile = path.resolve(project.resources_dir, path.basename(src));
53 53
            if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <resource-file>');
54 54
            if (fs.existsSync(destFile)) throw new CordovaError('target destination "' + destFile + '" already exists');
55 55
            project.xcode.addResourceFile(path.join('Resources', path.basename(src)));
56 56
            shell.cp('-R', srcFile, project.resources_dir);
57 57
        },
58 58
        uninstall: function (obj, plugin, project, options) {
59 -
            var src = obj.src;
60 -
            var destFile = path.resolve(project.resources_dir, path.basename(src));
59 +
            const src = obj.src;
60 +
            const destFile = path.resolve(project.resources_dir, path.basename(src));
61 61
            project.xcode.removeResourceFile(path.join('Resources', path.basename(src)));
62 62
            shell.rm('-rf', destFile);
63 63
        }
64 64
    },
65 65
    framework: { // CB-5238 custom frameworks only
66 66
        install: function (obj, plugin, project, options) {
67 -
            var src = obj.src;
68 -
            var custom = obj.custom;
67 +
            const src = obj.src;
68 +
            const custom = obj.custom;
69 69
70 70
            if (!custom) {
71 71
                if (keep_these_frameworks.indexOf(src) < 0) {
@@ -75,20 +75,20 @@
Loading
75 75
                return;
76 76
            }
77 77
78 -
            var srcFile = path.resolve(plugin.dir, src);
79 -
            var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
78 +
            const srcFile = path.resolve(plugin.dir, src);
79 +
            const targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
80 80
            if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <framework>');
81 81
            if (fs.existsSync(targetDir)) throw new CordovaError('target destination "' + targetDir + '" already exists');
82 82
            shell.mkdir('-p', path.dirname(targetDir));
83 83
            shell.cp('-R', srcFile, path.dirname(targetDir)); // frameworks are directories
84 -
            var project_relative = path.relative(project.projectDir, targetDir);
85 -
            var pbxFile = project.xcode.addFramework(project_relative, { customFramework: true });
84 +
            const project_relative = path.relative(project.projectDir, targetDir);
85 +
            const pbxFile = project.xcode.addFramework(project_relative, { customFramework: true });
86 86
            if (pbxFile) {
87 87
                project.xcode.addToPbxEmbedFrameworksBuildPhase(pbxFile);
88 88
            }
89 89
        },
90 90
        uninstall: function (obj, plugin, project, options) {
91 -
            var src = obj.src;
91 +
            const src = obj.src;
92 92
93 93
            if (!obj.custom) {
94 94
                if (keep_these_frameworks.indexOf(src) < 0) {
@@ -103,8 +103,8 @@
Loading
103 103
                return;
104 104
            }
105 105
106 -
            var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
107 -
            var pbxFile = project.xcode.removeFramework(targetDir, { customFramework: true });
106 +
            const targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
107 +
            const pbxFile = project.xcode.removeFramework(targetDir, { customFramework: true });
108 108
            if (pbxFile) {
109 109
                project.xcode.removeFromPbxEmbedFrameworksBuildPhase(pbxFile);
110 110
            }
@@ -128,18 +128,18 @@
Loading
128 128
                throw new CordovaError('<asset> tag without required "target" attribute');
129 129
            }
130 130
131 -
            var www = options.usePlatformWww ? project.platformWww : project.www;
131 +
            const www = options.usePlatformWww ? project.platformWww : project.www;
132 132
133 133
            copyFile(plugin.dir, obj.src, www, obj.target);
134 134
        },
135 135
        uninstall: function (obj, plugin, project, options) {
136 -
            var target = obj.target;
136 +
            const target = obj.target;
137 137
138 138
            if (!target) {
139 139
                throw new Error('<asset> tag without required "target" attribute');
140 140
            }
141 141
142 -
            var www = options.usePlatformWww ? project.platformWww : project.www;
142 +
            const www = options.usePlatformWww ? project.platformWww : project.www;
143 143
144 144
            removeFile(www, target);
145 145
            removeFileF(path.resolve(project.www, 'plugins', plugin.id));
@@ -148,24 +148,24 @@
Loading
148 148
    'js-module': {
149 149
        install: function (obj, plugin, project, options) {
150 150
            // Copy the plugin's files into the www directory.
151 -
            var moduleSource = path.resolve(plugin.dir, obj.src);
152 -
            var moduleName = plugin.id + '.' + (obj.name || path.parse(obj.src).name);
151 +
            const moduleSource = path.resolve(plugin.dir, obj.src);
152 +
            const moduleName = plugin.id + '.' + (obj.name || path.parse(obj.src).name);
153 153
154 154
            // Read in the file, prepend the cordova.define, and write it back out.
155 -
            var scriptContent = fs.readFileSync(moduleSource, 'utf-8').replace(/^\ufeff/, ''); // Window BOM
155 +
            let scriptContent = fs.readFileSync(moduleSource, 'utf-8').replace(/^\ufeff/, ''); // Window BOM
156 156
            if (moduleSource.match(/.*\.json$/)) {
157 157
                scriptContent = 'module.exports = ' + scriptContent;
158 158
            }
159 159
            scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) {\n' + scriptContent + '\n});\n';
160 160
161 -
            var www = options.usePlatformWww ? project.platformWww : project.www;
162 -
            var moduleDestination = path.resolve(www, 'plugins', plugin.id, obj.src);
161 +
            const www = options.usePlatformWww ? project.platformWww : project.www;
162 +
            const moduleDestination = path.resolve(www, 'plugins', plugin.id, obj.src);
163 163
            shell.mkdir('-p', path.dirname(moduleDestination));
164 164
            fs.writeFileSync(moduleDestination, scriptContent, 'utf-8');
165 165
        },
166 166
        uninstall: function (obj, plugin, project, options) {
167 -
            var pluginRelativePath = path.join('plugins', plugin.id, obj.src);
168 -
            var www = options.usePlatformWww ? project.platformWww : project.www;
167 +
            const pluginRelativePath = path.join('plugins', plugin.id, obj.src);
168 +
            const www = options.usePlatformWww ? project.platformWww : project.www;
169 169
            removeFileAndParents(www, pluginRelativePath);
170 170
        }
171 171
    }
@@ -188,14 +188,14 @@
Loading
188 188
};
189 189
190 190
function installHelper (type, obj, plugin_dir, project_dir, plugin_id, options, project) {
191 -
    var srcFile = path.resolve(plugin_dir, obj.src);
192 -
    var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
193 -
    var destFile = path.join(targetDir, path.basename(obj.src));
191 +
    const srcFile = path.resolve(plugin_dir, obj.src);
192 +
    const targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
193 +
    const destFile = path.join(targetDir, path.basename(obj.src));
194 194
195 -
    var project_ref;
196 -
    var link = !!(options && options.link);
195 +
    let project_ref;
196 +
    const link = !!(options && options.link);
197 197
    if (link) {
198 -
        var trueSrc = fs.realpathSync(srcFile);
198 +
        const trueSrc = fs.realpathSync(srcFile);
199 199
        // Create a symlink in the expected place, so that uninstall can use it.
200 200
        copyNewFile(plugin_dir, trueSrc, project_dir, destFile, link);
201 201
@@ -212,8 +212,8 @@
Loading
212 212
    if (type === 'header-file') {
213 213
        project.xcode.addHeaderFile(project_ref);
214 214
    } else if (obj.framework) {
215 -
        var opt = { weak: obj.weak };
216 -
        var project_relative = path.join(path.basename(project.xcode_path), project_ref);
215 +
        const opt = { weak: obj.weak };
216 +
        const project_relative = path.join(path.basename(project.xcode_path), project_ref);
217 217
        project.xcode.addFramework(project_relative, opt);
218 218
        project.xcode.addToLibrarySearchPaths({ path: project_ref });
219 219
    } else {
@@ -222,13 +222,13 @@
Loading
222 222
}
223 223
224 224
function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
225 -
    var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
226 -
    var destFile = path.join(targetDir, path.basename(obj.src));
225 +
    const targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
226 +
    const destFile = path.join(targetDir, path.basename(obj.src));
227 227
228 -
    var project_ref;
229 -
    var link = !!(options && options.link);
228 +
    let project_ref;
229 +
    const link = !!(options && options.link);
230 230
    if (link) {
231 -
        var trueSrc = fs.readlinkSync(destFile);
231 +
        const trueSrc = fs.readlinkSync(destFile);
232 232
        project_ref = 'Plugins/' + fixPathSep(path.relative(fs.realpathSync(project.plugins_dir), trueSrc));
233 233
    } else {
234 234
        project_ref = 'Plugins/' + fixPathSep(path.relative(project.plugins_dir, destFile));
@@ -239,7 +239,7 @@
Loading
239 239
    if (type === 'header-file') {
240 240
        project.xcode.removeHeaderFile(project_ref);
241 241
    } else if (obj.framework) {
242 -
        var project_relative = path.join(path.basename(project.xcode_path), project_ref);
242 +
        const project_relative = path.join(path.basename(project.xcode_path), project_ref);
243 243
        project.xcode.removeFramework(project_relative);
244 244
        project.xcode.removeFromLibrarySearchPaths({ path: project_ref });
245 245
    } else {
@@ -247,7 +247,7 @@
Loading
247 247
    }
248 248
}
249 249
250 -
var pathSepFix = new RegExp(path.sep.replace(/\\/, '\\\\'), 'g');
250 +
const pathSepFix = new RegExp(path.sep.replace(/\\/, '\\\\'), 'g');
251 251
function fixPathSep (file) {
252 252
    return file.replace(pathSepFix, '/');
253 253
}
@@ -257,8 +257,8 @@
Loading
257 257
    if (!fs.existsSync(src)) throw new CordovaError('"' + src + '" not found!');
258 258
259 259
    // check that src path is inside plugin directory
260 -
    var real_path = fs.realpathSync(src);
261 -
    var real_plugin_path = fs.realpathSync(plugin_dir);
260 +
    const real_path = fs.realpathSync(src);
261 +
    const real_plugin_path = fs.realpathSync(plugin_dir);
262 262
    if (real_path.indexOf(real_plugin_path) !== 0) { throw new CordovaError('"' + src + '" not located within plugin!'); }
263 263
264 264
    dest = path.resolve(project_dir, dest);
@@ -280,7 +280,7 @@
Loading
280 280
281 281
// Same as copy file but throws error if target exists
282 282
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
283 -
    var target_path = path.resolve(project_dir, dest);
283 +
    const target_path = path.resolve(project_dir, dest);
284 284
    if (fs.existsSync(target_path)) { throw new CordovaError('"' + target_path + '" already exists!'); }
285 285
286 286
    copyFile(plugin_dir, src, project_dir, dest, !!link);
@@ -288,7 +288,7 @@
Loading
288 288
289 289
// checks if file exists and then deletes. Error if doesn't exist
290 290
function removeFile (project_dir, src) {
291 -
    var file = path.resolve(project_dir, src);
291 +
    const file = path.resolve(project_dir, src);
292 292
    shell.rm('-Rf', file);
293 293
}
294 294
@@ -299,13 +299,13 @@
Loading
299 299
300 300
function removeFileAndParents (baseDir, destFile, stopper) {
301 301
    stopper = stopper || '.';
302 -
    var file = path.resolve(baseDir, destFile);
302 +
    const file = path.resolve(baseDir, destFile);
303 303
    if (!fs.existsSync(file)) return;
304 304
305 305
    removeFileF(file);
306 306
307 307
    // check if directory is empty
308 -
    var curDir = path.dirname(file);
308 +
    let curDir = path.dirname(file);
309 309
310 310
    while (curDir !== path.resolve(baseDir, stopper)) {
311 311
        if (fs.existsSync(curDir) && fs.readdirSync(curDir).length === 0) {

@@ -19,47 +19,47 @@
Loading
19 19
20 20
/* jshint node: true */
21 21
22 -
var xcode = require('xcode');
23 -
var plist = require('plist');
24 -
var _ = require('underscore');
25 -
var path = require('path');
26 -
var fs = require('fs');
27 -
var shell = require('shelljs');
22 +
const xcode = require('xcode');
23 +
const plist = require('plist');
24 +
const _ = require('underscore');
25 +
const path = require('path');
26 +
const fs = require('fs');
27 +
const shell = require('shelljs');
28 28
29 -
var pluginHandlers = require('./plugman/pluginHandlers');
30 -
var CordovaError = require('cordova-common').CordovaError;
29 +
const pluginHandlers = require('./plugman/pluginHandlers');
30 +
const CordovaError = require('cordova-common').CordovaError;
31 31
32 -
var cachedProjectFiles = {};
32 +
const cachedProjectFiles = {};
33 33
34 34
function parseProjectFile (locations) {
35 -
    var project_dir = locations.root;
36 -
    var pbxPath = locations.pbxproj;
35 +
    const project_dir = locations.root;
36 +
    const pbxPath = locations.pbxproj;
37 37
38 38
    if (cachedProjectFiles[project_dir]) {
39 39
        return cachedProjectFiles[project_dir];
40 40
    }
41 41
42 -
    var xcodeproj = xcode.project(pbxPath);
42 +
    const xcodeproj = xcode.project(pbxPath);
43 43
    xcodeproj.parseSync();
44 44
45 -
    var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
46 -
    var plist_file_entry = _.find(xcBuildConfiguration, function (entry) { return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE; });
47 -
    var plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
48 -
    var config_file = path.join(path.dirname(plist_file), 'config.xml');
45 +
    const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
46 +
    const plist_file_entry = _.find(xcBuildConfiguration, function (entry) { return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE; });
47 +
    const plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
48 +
    const config_file = path.join(path.dirname(plist_file), 'config.xml');
49 49
50 50
    if (!fs.existsSync(plist_file) || !fs.existsSync(config_file)) {
51 51
        throw new CordovaError('could not find -Info.plist file, or config.xml file.');
52 52
    }
53 53
54 -
    var frameworks_file = path.join(project_dir, 'frameworks.json');
55 -
    var frameworks = {};
54 +
    const frameworks_file = path.join(project_dir, 'frameworks.json');
55 +
    let frameworks = {};
56 56
    try {
57 57
        frameworks = require(frameworks_file);
58 58
    } catch (e) { }
59 59
60 -
    var xcode_dir = path.dirname(plist_file);
61 -
    var pluginsDir = path.resolve(xcode_dir, 'Plugins');
62 -
    var resourcesDir = path.resolve(xcode_dir, 'Resources');
60 +
    const xcode_dir = path.dirname(plist_file);
61 +
    const pluginsDir = path.resolve(xcode_dir, 'Plugins');
62 +
    const resourcesDir = path.resolve(xcode_dir, 'Resources');
63 63
64 64
    cachedProjectFiles[project_dir] = {
65 65
        plugins_dir: pluginsDir,
@@ -107,13 +107,13 @@
Loading
107 107
};
108 108
109 109
xcode.project.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
110 -
    var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
110 +
    const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
111 111
    if (sources) {
112 112
        sources.files.push(pbxBuildPhaseObj(file));
113 113
    }
114 114
};
115 115
xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) {
116 -
    var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
116 +
    const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
117 117
    if (sources) {
118 118
        sources.files = _.reject(sources.files, function (file) {
119 119
            return file.comment === longComment(file);
@@ -123,9 +123,9 @@
Loading
123 123
124 124
// special handlers to add frameworks to the 'Embed Frameworks' build phase, needed for custom frameworks
125 125
// see CB-9517. should probably be moved to node-xcode.
126 -
var util = require('util');
126 +
const util = require('util');
127 127
function pbxBuildPhaseObj (file) {
128 -
    var obj = Object.create(null);
128 +
    const obj = Object.create(null);
129 129
    obj.value = file.uuid;
130 130
    obj.comment = longComment(file);
131 131
    return obj;

@@ -19,10 +19,10 @@
Loading
19 19
    under the License.
20 20
*/
21 21
22 -
var shell = require('shelljs');
23 -
var path = require('path');
24 -
var fs = require('fs');
25 -
var ROOT = path.join(__dirname, '..', '..');
22 +
const shell = require('shelljs');
23 +
const path = require('path');
24 +
const fs = require('fs');
25 +
const ROOT = path.join(__dirname, '..', '..');
26 26
27 27
function updateSubprojectHelp () {
28 28
    console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.');
@@ -30,7 +30,7 @@
Loading
30 30
}
31 31
32 32
function setShellFatal (value, func) {
33 -
    var oldVal = shell.config.fatal;
33 +
    const oldVal = shell.config.fatal;
34 34
    shell.config.fatal = value;
35 35
    func();
36 36
    shell.config.fatal = oldVal;
@@ -57,9 +57,9 @@
Loading
57 57
            // like it should).
58 58
            fs.symlinkSync(path.join(ROOT, 'CordovaLib'), path.join(projectPath, 'CordovaLib'));
59 59
        } else {
60 -
            var r = path.join(projectPath, projectName);
61 -
            var srcLib = path.join(ROOT, 'CordovaLib');
62 -
            var dstLib = path.join(projectPath, 'CordovaLib');
60 +
            const r = path.join(projectPath, projectName);
61 +
            const srcLib = path.join(ROOT, 'CordovaLib');
62 +
            const dstLib = path.join(projectPath, 'CordovaLib');
63 63
            shell.mkdir('-p', path.join(dstLib, 'CordovaLib.xcodeproj'));
64 64
            shell.cp('-f', path.join(r, '.gitignore'), projectPath);
65 65
            shell.cp('-rf', path.join(srcLib, 'CordovaLib'), dstLib);
@@ -73,14 +73,14 @@
Loading
73 73
}
74 74
75 75
function copyScripts (projectPath) {
76 -
    var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
77 -
    var destScriptsDir = path.join(projectPath, 'cordova');
76 +
    const srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
77 +
    const destScriptsDir = path.join(projectPath, 'cordova');
78 78
79 79
    // Delete old scripts directory.
80 80
    shell.rm('-rf', destScriptsDir);
81 81
82 82
    // Copy in the new ones.
83 -
    var binDir = path.join(ROOT, 'bin');
83 +
    const binDir = path.join(ROOT, 'bin');
84 84
    shell.cp('-r', srcScriptsDir, projectPath);
85 85
86 86
    const nodeModulesDir = path.join(ROOT, 'node_modules');
@@ -102,9 +102,9 @@
Loading
102 102
}
103 103
104 104
function detectProjectName (projectDir) {
105 -
    var files = fs.readdirSync(projectDir);
106 -
    for (var i = 0; i < files.length; ++i) {
107 -
        var m = /(.*)\.xcodeproj$/.exec(files[i]);
105 +
    const files = fs.readdirSync(projectDir);
106 +
    for (let i = 0; i < files.length; ++i) {
107 +
        const m = /(.*)\.xcodeproj$/.exec(files[i]);
108 108
        if (m) {
109 109
            return m[1];
110 110
        }
@@ -117,7 +117,7 @@
Loading
117 117
}
118 118
119 119
function AbsProjectPath (relative_path) {
120 -
    var absolute_path = path.resolve(relative_path);
120 +
    let absolute_path = path.resolve(relative_path);
121 121
    if (/.pbxproj$/.test(absolute_path)) {
122 122
        absolute_path = AbsParentPath(absolute_path);
123 123
    } else if (!(/.xcodeproj$/.test(absolute_path))) {
@@ -145,10 +145,10 @@
Loading
145 145
exports.createProject = function (project_path, package_name, project_name, opts, events) {
146 146
    package_name = package_name || 'my.cordova.project';
147 147
    project_name = project_name || 'CordovaExample';
148 -
    var use_shared = !!opts.link;
149 -
    var bin_dir = path.join(ROOT, 'bin');
150 -
    var project_parent = path.dirname(project_path);
151 -
    var project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project');
148 +
    const use_shared = !!opts.link;
149 +
    const bin_dir = path.join(ROOT, 'bin');
150 +
    const project_parent = path.dirname(project_path);
151 +
    const project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project');
152 152
153 153
    // check that project path doesn't exist
154 154
    if (fs.existsSync(project_path)) {
@@ -168,12 +168,12 @@
Loading
168 168
    shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
169 169
    shell.mv(path.join(project_path, '__PROJECT_NAME__'), path.join(project_path, project_name));
170 170
171 -
    var r = path.join(project_path, project_name);
171 +
    const r = path.join(project_path, project_name);
172 172
    shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name + '-Info.plist'));
173 173
    shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name + '-Prefix.pch'));
174 174
    shell.mv(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
175 175
176 -
    var project_name_esc = project_name.replace(/&/g, '\\&');
176 +
    const project_name_esc = project_name.replace(/&/g, '\\&');
177 177
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r + '.xcodeproj', 'project.pbxproj'));
178 178
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
179 179
    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
@@ -196,7 +196,7 @@
Loading
196 196
};
197 197
198 198
exports.updateProject = function (projectPath, opts, events) {
199 -
    var projectName = detectProjectName(projectPath);
199 +
    const projectName = detectProjectName(projectPath);
200 200
    setShellFatal(true, function () {
201 201
        copyJsAndCordovaLib(projectPath, projectName, opts.link);
202 202
        copyScripts(projectPath);
@@ -206,8 +206,8 @@
Loading
206 206
};
207 207
208 208
function generateDoneMessage (type, link) {
209 -
    var pkg = require('../../package');
210 -
    var msg = 'OS X project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
209 +
    const pkg = require('../../package');
210 +
    let msg = 'OS X project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
211 211
    if (link) {
212 212
        msg += ' and has a linked CordovaLib';
213 213
    }
@@ -220,24 +220,24 @@
Loading
220 220
        throw new Error('Usage error for update_cordova_subproject');
221 221
    }
222 222
223 -
    var projectPath = AbsProjectPath(argv[0]);
224 -
    var cordovaLibXcodePath;
223 +
    const projectPath = AbsProjectPath(argv[0]);
224 +
    let cordovaLibXcodePath;
225 225
    if (argv.length < 2) {
226 226
        cordovaLibXcodePath = path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj');
227 227
    } else {
228 228
        cordovaLibXcodePath = AbsProjectPath(argv[1]);
229 229
    }
230 230
231 -
    var parentProjectPath = AbsParentPath(projectPath);
232 -
    var subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath);
233 -
    var REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
234 -
    var newLine;
235 -
    var lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj'));
236 -
    var found = false;
231 +
    const parentProjectPath = AbsParentPath(projectPath);
232 +
    let subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath);
233 +
    const REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
234 +
    let newLine;
235 +
    let lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj'));
236 +
    let found = false;
237 237
238 238
    subprojectPath = subprojectPath.replace(/\\/g, '/');
239 239
    lines = lines.split('\n');
240 -
    for (var i = 0; i < lines.length; ++i) {
240 +
    for (let i = 0; i < lines.length; ++i) {
241 241
        if (lines[i].match(REGEX)) {
242 242
            found = true;
243 243
            /* eslint-disable no-useless-escape */
@@ -252,8 +252,8 @@
Loading
252 252
253 253
    // Patching pbxproj to replace copy www shell script with nodejs
254 254
    // Don't forget to duplicate this in templates/__CLI__.xcodeproj/project.pbxproj and templates/__PROJECT_NAME__.xcodeproj/project.pbxproj on later changes
255 -
    var copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh';
256 -
    var copyWwwJs = 'NODEJS_PATH=\/usr\/local\/bin; NVM_NODE_PATH=~\/\.nvm\/versions\/node\/`nvm version 2>\/dev\/null`\/bin; N_NODE_PATH=`find \/usr\/local\/n\/versions\/node\/\* -maxdepth 0 -type d 2>\/dev\/null \| tail -1`\/bin; XCODE_NODE_PATH=`xcode-select --print-path`\/usr\/share\/xcs\/Node\/bin; PATH=\$NODEJS_PATH:\$NVM_NODE_PATH:\$N_NODE_PATH:\$XCODE_NODE_PATH:\$PATH && node cordova\/lib\/copy-www-build-step\.js';
255 +
    const copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh';
256 +
    const copyWwwJs = 'NODEJS_PATH=\/usr\/local\/bin; NVM_NODE_PATH=~\/\.nvm\/versions\/node\/`nvm version 2>\/dev\/null`\/bin; N_NODE_PATH=`find \/usr\/local\/n\/versions\/node\/\* -maxdepth 0 -type d 2>\/dev\/null \| tail -1`\/bin; XCODE_NODE_PATH=`xcode-select --print-path`\/usr\/share\/xcs\/Node\/bin; PATH=\$NODEJS_PATH:\$NVM_NODE_PATH:\$N_NODE_PATH:\$XCODE_NODE_PATH:\$PATH && node cordova\/lib\/copy-www-build-step\.js';
257 257
    shell.sed('-i', copyWwwSh, copyWwwJs, path.join(projectPath, 'project.pbxproj'));
258 258
259 259
    /* eslint-enable no-useless-escape */

@@ -17,10 +17,10 @@
Loading
17 17
    under the License.
18 18
*/
19 19
20 -
var loggerInstance;
21 -
var util = require('util');
22 -
var EventEmitter = require('events').EventEmitter;
23 -
var CordovaError = require('cordova-common').CordovaError;
20 +
let loggerInstance;
21 +
const util = require('util');
22 +
const EventEmitter = require('events').EventEmitter;
23 +
const CordovaError = require('cordova-common').CordovaError;
24 24
25 25
/**
26 26
 * @class ConsoleLogger
@@ -36,7 +36,7 @@
Loading
36 36
function ConsoleLogger () {
37 37
    EventEmitter.call(this);
38 38
39 -
    var isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0;
39 +
    const isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0;
40 40
    // For CordovaError print only the message without stack trace unless we
41 41
    // are in a verbose mode.
42 42
    process.on('uncaughtException', function (err) {

@@ -17,13 +17,13 @@
Loading
17 17
    under the License.
18 18
*/
19 19
20 -
var fs = require('fs');
21 -
var path = require('path');
20 +
const fs = require('fs');
21 +
const path = require('path');
22 22
23 -
var PluginManager = require('cordova-common').PluginManager;
24 -
var projectFile = require('./lib/projectFile');
25 -
var CordovaError = require('cordova-common').CordovaError;
26 -
var ConsoleLogger = require('./lib/ConsoleLogger');
23 +
const PluginManager = require('cordova-common').PluginManager;
24 +
const projectFile = require('./lib/projectFile');
25 +
const CordovaError = require('cordova-common').CordovaError;
26 +
const ConsoleLogger = require('./lib/ConsoleLogger');
27 27
28 28
/**
29 29
 * Creates a new PlatformApi instance.
@@ -45,8 +45,8 @@
Loading
45 45
    // NOTE: trick to share one EventEmitter instance across all js code
46 46
    require('cordova-common').events = this.events;
47 47
48 -
    var xcodeProjDir;
49 -
    var xcodeCordovaProj;
48 +
    let xcodeProjDir;
49 +
    let xcodeCordovaProj;
50 50
51 51
    try {
52 52
        xcodeProjDir = fs.readdirSync(this.root).filter(function (e) { return e.match(/\.xcodeproj$/i); })[0];
@@ -54,7 +54,7 @@
Loading
54 54
            throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
55 55
        }
56 56
57 -
        var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj'));
57 +
        const cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj'));
58 58
        xcodeCordovaProj = path.join(this.root, cordovaProjName);
59 59
    } catch (e) {
60 60
        throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
@@ -100,7 +100,7 @@
Loading
100 100
        .then(function () {
101 101
            // after platform is created we return Api instance based on new Api.js location
102 102
            // This is required to correctly resolve paths in the future api calls
103 -
            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
103 +
            const PlatformApi = require(path.resolve(destination, 'cordova/Api'));
104 104
            return new PlatformApi('osx', destination, events);
105 105
        });
106 106
};
@@ -125,7 +125,7 @@
Loading
125 125
    return require('../../../lib/create')
126 126
        .updateProject(destination, options, events || ConsoleLogger.get())
127 127
        .then(function () {
128 -
            var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
128 +
            const PlatformApi = require(path.resolve(destination, 'cordova/Api'));
129 129
            return new PlatformApi('android', destination, events);
130 130
        });
131 131
};
@@ -137,7 +137,7 @@
Loading
137 137
 *   platform's file structure and other properties of platform.
138 138
 */
139 139
Api.prototype.getPlatformInfo = function () {
140 -
    var result = {};
140 +
    const result = {};
141 141
    result.locations = this.locations;
142 142
    result.root = this.root;
143 143
    result.name = this.platform;
@@ -183,7 +183,7 @@
Loading
183 183
 *   CordovaError instance.
184 184
 */
185 185
Api.prototype.addPlugin = function (plugin, installOptions) {
186 -
    var xcodeproj = projectFile.parse(this.locations);
186 +
    const xcodeproj = projectFile.parse(this.locations);
187 187
    return PluginManager.get(this.platform, this.locations, xcodeproj).addPlugin(plugin, installOptions);
188 188
};
189 189
@@ -201,7 +201,7 @@
Loading
201 201
 *   CordovaError instance.
202 202
 */
203 203
Api.prototype.removePlugin = function (plugin, uninstallOptions) {
204 -
    var xcodeproj = projectFile.parse(this.locations);
204 +
    const xcodeproj = projectFile.parse(this.locations);
205 205
    return PluginManager.get(this.platform, this.locations, xcodeproj).removePlugin(plugin, uninstallOptions);
206 206
};
207 207
@@ -238,7 +238,7 @@
Loading
238 238
 *   CordovaError instance.
239 239
 */
240 240
Api.prototype.build = function (buildOptions) {
241 -
    var self = this;
241 +
    const self = this;
242 242
    return require('./lib/check_reqs').run()
243 243
        .then(function () {
244 244
            return require('./lib/build').run.call(self, buildOptions);
@@ -258,7 +258,7 @@
Loading
258 258
 *   successfully, or rejected with CordovaError.
259 259
 */
260 260
Api.prototype.run = function (runOptions) {
261 -
    var self = this;
261 +
    const self = this;
262 262
    return require('./lib/check_reqs').run()
263 263
        .then(function () {
264 264
            return require('./lib/run').run.call(self, runOptions);
@@ -272,7 +272,7 @@
Loading
272 272
 *   CordovaError.
273 273
 */
274 274
Api.prototype.clean = function (cleanOptions) {
275 -
    var self = this;
275 +
    const self = this;
276 276
    return require('./lib/check_reqs').run()
277 277
        .then(function () {
278 278
            return require('./lib/clean').run.call(self, cleanOptions);
Files Coverage
bin 39.20%
Project Totals (5 files) 39.20%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading