Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8DB4E100C9 for ; Sat, 14 Feb 2015 00:01:10 +0000 (UTC) Received: (qmail 21608 invoked by uid 500); 14 Feb 2015 00:01:10 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 21581 invoked by uid 500); 14 Feb 2015 00:01:10 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 21567 invoked by uid 99); 14 Feb 2015 00:01:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2015 00:01:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2B575E05DA; Sat, 14 Feb 2015 00:01:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ios commit: CB-8435 Enable jshint for iOS platform Date: Sat, 14 Feb 2015 00:01:10 +0000 (UTC) Repository: cordova-ios Updated Branches: refs/heads/master 338ee71f9 -> f7a888140 CB-8435 Enable jshint for iOS platform Signed-off-by: Shazron Abdullah Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f7a88814 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f7a88814 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f7a88814 Branch: refs/heads/master Commit: f7a888140951e1952acd40f3ec54d13726f2fae4 Parents: 338ee71 Author: Murat Sutunc Authored: Thu Feb 5 12:03:37 2015 -0800 Committer: Shazron Abdullah Committed: Fri Feb 13 15:39:02 2015 -0800 ---------------------------------------------------------------------- .jshintignore | 2 ++ .jshintrc | 10 ++++++ .travis.yml | 5 ++- bin/lib/create.js | 25 +++++++------- bin/lib/versions.js | 6 ++-- bin/templates/scripts/cordova/lib/build.js | 34 +++++++++--------- bin/templates/scripts/cordova/lib/clean.js | 2 +- bin/templates/scripts/cordova/lib/run.js | 46 ++++++++++++------------- package.json | 9 +++-- tests/.jshintrc | 11 ++++++ tests/spec/cordovalib.spec.js | 2 +- 11 files changed, 91 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/.jshintignore ---------------------------------------------------------------------- diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..e87aa4b --- /dev/null +++ b/.jshintignore @@ -0,0 +1,2 @@ +bin/node_modules/* +bin/templates/project/* http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/.jshintrc ---------------------------------------------------------------------- diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..89a121c --- /dev/null +++ b/.jshintrc @@ -0,0 +1,10 @@ +{ + "node": true + , "bitwise": true + , "undef": true + , "trailing": true + , "quotmark": true + , "indent": 4 + , "unused": "vars" + , "latedef": "nofunc" +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index 74f77cc..31a8812 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: objective-c sudo: false -install: npm install +install: +- npm install +- npm install ios-sim +- npm install ios-deploy script: "npm test" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/bin/lib/create.js ---------------------------------------------------------------------- diff --git a/bin/lib/create.js b/bin/lib/create.js index ec762ac..cbffd63 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -26,18 +26,18 @@ var shell = require('shelljs'), ROOT = path.join(__dirname, '..', '..'); function createHelp() { - console.log("Usage: $0 [--link] [--cli] []"); - console.log(" --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it."); - console.log(" --cli (optional): Use the CLI-project template."); - console.log(" : Path to your new Cordova iOS project"); - console.log(" : Package name, following reverse-domain style convention"); - console.log(" : Project name"); - console.log(" : Path to project template (override)."); + console.log('Usage: $0 [--link] [--cli] []'); + console.log(' --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.'); + console.log(' --cli (optional): Use the CLI-project template.'); + console.log(' : Path to your new Cordova iOS project'); + console.log(' : Package name, following reverse-domain style convention'); + console.log(' : Project name'); + console.log(' : Path to project template (override).'); } function updateSubprojectHelp() { - console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.') - console.log("Usage: CordovaVersion/bin/update_cordova_project path/to/your/app.xcodeproj [path/to/CordovaLib.xcodeproj]"); + console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.'); + console.log('Usage: CordovaVersion/bin/update_cordova_project path/to/your/app.xcodeproj [path/to/CordovaLib.xcodeproj]'); } function setShellFatal(value, func) { @@ -103,10 +103,10 @@ function detectProjectName(projectDir) { for (var i = 0; i < files.length; ++i) { var m = /(.*)\.xcodeproj$/.exec(files[i]); if (m) { - return m[1] + return m[1]; } } - throw new Exception('Could not find an .xcodeproj directory within ' + projectDir); + throw new Error('Could not find an .xcodeproj directory within ' + projectDir); } function AbsParentPath(_path) { @@ -146,7 +146,6 @@ exports.createProject = function(project_path, package_name, project_name, opts) var use_shared = !!opts.link; var use_cli = !!opts.cli; var bin_dir = path.join(ROOT, 'bin'), - cordovalib_dir = path.join(ROOT, 'CordovaLib'), project_parent = path.dirname(project_path); var project_template_dir = opts.project_template_dir || path.join(bin_dir, 'templates', 'project'); @@ -205,7 +204,7 @@ exports.createProject = function(project_path, package_name, project_name, opts) console.log(generateDoneMessage('create', use_shared)); return Q.resolve(); -} +}; exports.updateProject = function(projectPath, opts) { var projectName = detectProjectName(projectPath); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/bin/lib/versions.js ---------------------------------------------------------------------- diff --git a/bin/lib/versions.js b/bin/lib/versions.js index 78f3ec5..e22e499 100755 --- a/bin/lib/versions.js +++ b/bin/lib/versions.js @@ -49,7 +49,7 @@ exports.get_apple_ios_version = function() { }, function(stderr) { return Q.reject(stderr); }); -} +}; exports.get_apple_osx_version = function() { var d = Q.defer(); @@ -78,7 +78,7 @@ exports.get_apple_osx_version = function() { }, function(stderr) { return Q.reject(stderr); }); -} +}; exports.get_apple_xcode_version = function() { var d = Q.defer(); @@ -158,7 +158,7 @@ exports.compareVersions = function (version1, version2) { // Number constructor is strict enough and will return NaN // if conversion fails. In this case we won't be able to compare versions properly if (isNaN(parsed)) { - throw "Version should contain only numbers and dots"; + throw 'Version should contain only numbers and dots'; } return parsed; }); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/bin/templates/scripts/cordova/lib/build.js ---------------------------------------------------------------------- diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js index 02d8113..ff3d625 100644 --- a/bin/templates/scripts/cordova/lib/build.js +++ b/bin/templates/scripts/cordova/lib/build.js @@ -51,9 +51,9 @@ module.exports.run = function (argv) { }).then(function (projectName) { var configuration = args.release ? 'Release' : 'Debug'; - console.log("Building project : " + path.join(projectPath, projectName + '.xcodeproj')); - console.log("\tConfiguration : " + configuration); - console.log("\tPlatform : " + (args.device ? 'device' : 'emulator')); + console.log('Building project : ' + path.join(projectPath, projectName + '.xcodeproj')); + console.log('\tConfiguration : ' + configuration); + console.log('\tPlatform : ' + (args.device ? 'device' : 'emulator')); var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration, args.device); return spawn('xcodebuild', xcodebuildArgs, projectPath); @@ -72,7 +72,7 @@ function findXCodeProjectIn(projectPath) { }); if (xcodeProjFiles.length === 0) { - return Q.reject("No Xcode project found in " + projectPath); + return Q.reject('No Xcode project found in ' + projectPath); } if (xcodeProjFiles.length > 1) { console.warn('Found multiple .xcodeproj directories in \n' + @@ -127,22 +127,22 @@ function getXcodeArgs(projectName, projectPath, configuration, isDevice) { // help/usage function module.exports.help = function help() { - console.log(""); - console.log("Usage: build [ --debug | --release ] [--archs=\"\"] [--device | --simulator]"); - console.log(" --help : Displays this dialog."); - console.log(" --debug : Builds project in debug mode. (Default)"); - console.log(" --release : Builds project in release mode."); - console.log(" -r : Shortcut :: builds project in release mode."); + console.log(''); + console.log('Usage: build [ --debug | --release ] [--archs=\"\"] [--device | --simulator]'); + console.log(' --help : Displays this dialog.'); + console.log(' --debug : Builds project in debug mode. (Default)'); + console.log(' --release : Builds project in release mode.'); + console.log(' -r : Shortcut :: builds project in release mode.'); // TODO: add support for building different archs // console.log(" --archs : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`)."); - console.log(" --device, --simulator"); - console.log(" : Specifies, what type of project to build"); - console.log("examples:"); - console.log(" build "); - console.log(" build --debug"); - console.log(" build --release"); + console.log(' --device, --simulator'); + console.log(' : Specifies, what type of project to build'); + console.log('examples:'); + console.log(' build '); + console.log(' build --debug'); + console.log(' build --release'); // TODO: add support for building different archs // console.log(" build --release --archs=\"armv7\""); - console.log(""); + console.log(''); process.exit(0); }; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/bin/templates/scripts/cordova/lib/clean.js ---------------------------------------------------------------------- diff --git a/bin/templates/scripts/cordova/lib/clean.js b/bin/templates/scripts/cordova/lib/clean.js index 75ac18e..6d955cf 100644 --- a/bin/templates/scripts/cordova/lib/clean.js +++ b/bin/templates/scripts/cordova/lib/clean.js @@ -33,7 +33,7 @@ module.exports.run = function() { })[0]; if (!projectName) { - return Q.reject("No Xcode project found in " + projectPath); + return Q.reject('No Xcode project found in ' + projectPath); } return check_reqs.run().then(function() { http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/bin/templates/scripts/cordova/lib/run.js ---------------------------------------------------------------------- diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js index 53153fc..151cad2 100644 --- a/bin/templates/scripts/cordova/lib/run.js +++ b/bin/templates/scripts/cordova/lib/run.js @@ -36,9 +36,9 @@ module.exports.run = function (argv) { // but still valid since they can be passed down to build command var args = nopt({ // "archs": String, // TODO: add support for building different archs - "list": Boolean, - "nobuild": Boolean, - "device": Boolean, "emulator": Boolean, "target": String + 'list': Boolean, + 'nobuild': Boolean, + 'device': Boolean, 'emulator': Boolean, 'target': String }, {}, argv); // Validate args @@ -48,10 +48,10 @@ module.exports.run = function (argv) { // validate target device for ios-sim // Valid values for "--target" (case sensitive): - var validTargets = ["iPhone-4s", "iPhone-5", "iPhone-5s", "iPhone-6-Plus", "iPhone-6", - "iPad-2", "iPad-Retina", "iPad-Air", "Resizable-iPhone", "Resizable-iPad"]; + var validTargets = ['iPhone-4s', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6', + 'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad']; if (args.target && validTargets.indexOf(args.target) < 0 ) { - return Q.reject(args.target + " is not a valid target for emulator"); + return Q.reject(args.target + ' is not a valid target for emulator'); } // support for CB-8168 `cordova/run --list` @@ -136,7 +136,7 @@ function deployToSim(appPath, target) { function listDevices() { return require('./list-devices').run() .then(function (devices) { - console.log("Available iOS Devices:"); + console.log('Available iOS Devices:'); devices.forEach(function (device) { console.log('\t' + device); }); @@ -146,7 +146,7 @@ function listDevices() { function listEmulators() { return require('./list-emulator-images').run() .then(function (emulators) { - console.log("Available iOS Virtual Devices:"); + console.log('Available iOS Virtual Devices:'); emulators.forEach(function (emulator) { console.log('\t' + emulator); }); @@ -154,24 +154,24 @@ function listEmulators() { } module.exports.help = function () { - console.log("\nUsage: run [ --device | [ --emulator [ --target= ] ] ] [ --debug | --release | --nobuild ]"); + console.log('\nUsage: run [ --device | [ --emulator [ --target= ] ] ] [ --debug | --release | --nobuild ]'); // TODO: add support for building different archs // console.log(" [ --archs=\"\" ] "); - console.log(" --device : Deploys and runs the project on the connected device."); - console.log(" --emulator : Deploys and runs the project on an emulator."); - console.log(" --target= : Deploys and runs the project on the specified target."); - console.log(" --debug : Builds project in debug mode. (Passed down to build command, if necessary)"); - console.log(" --release : Builds project in release mode. (Passed down to build command, if necessary)"); - console.log(" --nobuild : Uses pre-built package, or errors if project is not built."); + console.log(' --device : Deploys and runs the project on the connected device.'); + console.log(' --emulator : Deploys and runs the project on an emulator.'); + console.log(' --target= : Deploys and runs the project on the specified target.'); + console.log(' --debug : Builds project in debug mode. (Passed down to build command, if necessary)'); + console.log(' --release : Builds project in release mode. (Passed down to build command, if necessary)'); + console.log(' --nobuild : Uses pre-built package, or errors if project is not built.'); // TODO: add support for building different archs // console.log(" --archs : Specific chip architectures (`anycpu`, `arm`, `x86`, `x64`)."); - console.log(""); - console.log("Examples:"); - console.log(" run"); - console.log(" run --device"); - console.log(" run --emulator --target=\"iPhone-6-Plus\""); - console.log(" run --device --release"); - console.log(" run --emulator --debug"); - console.log(""); + console.log(''); + console.log('Examples:'); + console.log(' run'); + console.log(' run --device'); + console.log(' run --emulator --target=\"iPhone-6-Plus\"'); + console.log(' run --device --release'); + console.log(' run --emulator --debug'); + console.log(''); process.exit(0); }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 1714e4d..2f4b5d4 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,10 @@ "apache" ], "scripts": { - "test": "npm run jasmine", - "jasmine": "jasmine-node --captureExceptions --color tests/spec" + "test": "npm run jshint && npm run jasmine", + "jasmine": "jasmine-node --captureExceptions --color tests/spec", + "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", "license": "Apache Version 2.0", @@ -23,5 +25,8 @@ "shelljs": "^0.2.6", "coffee-script": "^1.7.1", "nodeunit": "^0.8.7" + }, + "devDependencies": { + "jshint": "^2.6.0" } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/tests/.jshintrc ---------------------------------------------------------------------- diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 0000000..17eae32 --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,11 @@ +{ + "node": true + , "bitwise": true + , "undef": true + , "trailing": true + , "quotmark": true + , "indent": 4 + , "unused": "vars" + , "latedef": "nofunc" + , "jasmine": true +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7a88814/tests/spec/cordovalib.spec.js ---------------------------------------------------------------------- diff --git a/tests/spec/cordovalib.spec.js b/tests/spec/cordovalib.spec.js index dc581ff..10cd696 100644 --- a/tests/spec/cordovalib.spec.js +++ b/tests/spec/cordovalib.spec.js @@ -36,7 +36,7 @@ describe('cordova-lib', function() { return_code = shell.exec(command).code; // if iOS Simulator is running, kill it - if (return_code == 0) { // found + if (return_code === 0) { // found shell.echo('iOS Simulator is running, we\'re going to kill it.'); return_code = shell.exec('killall "iOS Simulator"').code; expect(return_code).toBe(0); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org