diff --git a/check_reqs.js b/check_reqs.js index fda89da..ce06b73 100755 --- a/check_reqs.js +++ b/check_reqs.js @@ -1,32 +1,45 @@ #!/usr/bin/env node -var shell = require('shelljs'); var util = require('util'); var os = require('os'); +var child_process = require('child_process'); var XCODEBUILD_MIN_VERSION = '6.4'; -var XCODEBUILD_NOT_FOUND_MESSAGE = - 'Please install Xcode version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store'; - -var tool = 'xcodebuild' -var tool_command = shell.which(tool); -if (!tool_command) { - console.log(tool + ' : ' + XCODEBUILD_NOT_FOUND_MESSAGE); - process.exit(1); -} +var XCODEBUILD_NOT_FOUND_MESSAGE = util.format('Please install Xcode version %s or greater from the Mac App Store.', XCODEBUILD_MIN_VERSION); +var TOOL = 'xcodebuild'; -shell.exec(tool + ' -version', { silent: true }, function(code, output) { +var xcode_version = child_process.spawn(TOOL, ['-version']), + version_string = ''; + +xcode_version.stdout.on('data', function (data) { + version_string += data; +}); + +xcode_version.stderr.on('data', function (data) { + console.log('stderr: ' + data); +}); + +xcode_version.on('error', function (err) { + console.log(util.format('Tool %s was not found. %s', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE)); +}); + +xcode_version.on('close', function (code) { if (code === 0) { - var arr = output.match(/^Xcode (\d+\.\d+)/); + var arr = version_string.match(/^Xcode (\d+\.\d+)/); var ver = arr[1]; if (os.release() >= '15.0.0' && ver < '7.0') { - console.log(util.format('You need at least Xcode 7.0 on OS X 10.11 El Capitan (you have version %s)', ver)); + console.log(util.format('You need at least Xcode 7.0 when you are on OS X 10.11 El Capitan (you have version %s)', ver)); process.exit(1); } - + if (ver < XCODEBUILD_MIN_VERSION) { console.log(util.format('%s : %s. (you have version %s)', tool, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); } - } -}); \ No newline at end of file + } + process.exit(code); +}); + + + + diff --git a/package.json b/package.json index 564034a..c279b07 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,6 @@ "type": "git", "url": "https://github.com/phonegap/ios-deploy" }, - "dependencies": { - "shelljs": "^0.2.6" - }, "keywords": [ "ios-deploy", "deploy to iOS device"