Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
CB-9097 fail with a more descriptive error if run as admin
Browse files Browse the repository at this point in the history
  • Loading branch information
muratsu committed May 29, 2015
1 parent ed04ee1 commit b34a5f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion template/cordova/lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var Q = require('q'),
build = require('./build'),
utils = require('./utils'),
ConfigParser = require('./ConfigParser'),
packages = require('./package');
packages = require('./package'),
execSync = require('child_process').execSync;

var ROOT = path.join(__dirname, '..', '..');

Expand All @@ -32,6 +33,13 @@ module.exports.run = function (argv) {
return Q.reject('Could not find project at ' + ROOT);
}

try {
// Check if ran from admin prompt and fail quickly if CLI has administrative permissions
// http://stackoverflow.com/a/11995662/64949
execSync('net session', {'stdio': 'ignore'});
return Q.reject('Can not run this platform with administrative permissions. Please run from a non-admin prompt.');
} catch (e) {}

// parse arg
var args = nopt({'debug': Boolean, 'release': Boolean, 'nobuild': Boolean,
'device': Boolean, 'emulator': Boolean, 'target': String, 'archs': String,
Expand Down

0 comments on commit b34a5f1

Please sign in to comment.