MCPcopy
hub / github.com/bower/bower / rootCheck

Function rootCheck

lib/util/rootCheck.js:6–32  ·  view source on GitHub ↗
(options, config)

Source from the content-addressed store, hash-verified

4var renderer;
5
6function rootCheck(options, config) {
7 var errorMsg;
8
9 // Allow running the command as root
10 if (options.allowRoot || config.allowRoot) {
11 return;
12 }
13
14 errorMsg =
15 'Since bower is a user command, there is no need to execute it with \
16superuser permissions.\nIf you\'re having permission errors when using bower without \
17sudo, please spend a few minutes learning more about how your system should work and \
18make any necessary repairs.\n\n\
19http://www.joyent.com/blog/installing-node-and-npm\n\
20https://gist.github.com/isaacs/579814\n\n\
21You can however run a command with sudo using "--allow-root" option';
22
23 if (isRoot()) {
24 var cli = require('./cli');
25 renderer = cli.getRenderer('', false, config);
26 renderer.error(
27 createError('Please do not run with sudo', 'ESUDO', {
28 details: errorMsg
29 })
30 );
31 }
32}
33
34module.exports = rootCheck;

Callers 1

bower.jsFile · 0.85

Calls 1

createErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…