Skip to content

Commit

Permalink
Moved check_reqs.js to src, added jshint to npm test
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron committed Oct 12, 2015
1 parent 6f65bb6 commit 1220cac
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,27 @@
"description": "launch iOS apps iOS devices from the command line (Xcode 7)",
"main": "ios-deploy",
"scripts": {
"preinstall": "./check_reqs.js && xcodebuild"
"preinstall": "./src/check_reqs.js && xcodebuild"
},
"bin": "./build/Release/ios-deploy",
"repository": {
"type": "git",
"url": "https://github.com/phonegap/ios-deploy"
},
"devDependencies": {
"jshint": "2.5.8"
},
"scripts": {
"test": "npm run jshint",
"jshint": "node node_modules/jshint/bin/jshint src"
},
"keywords": [
"ios-deploy",
"deploy to iOS device"
],
"bugs": {
"url": "https://github.com/phonegap/ios-deploy/issues"
},
"author": "Greg Hughes",
"license": "GPLv3"
}
45 changes: 45 additions & 0 deletions src/check_reqs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node

var util = require('util');
var os = require('os');
var child_process = require('child_process');

var XCODEBUILD_MIN_VERSION = '6.0';
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';

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 = 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 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));
}
}
process.exit(code);
});




0 comments on commit 1220cac

Please sign in to comment.