Prompts the user to install the udev rules.

@param {Error} [err] Original error that led to this prompt.
@return {Promise}
973386
function promptAndInstallUdevRules(err = null) {
	if (!systemSupportsUdev()) {
		return when.reject(new Error('Not supported'));
	}
	if (udevRulesInstalled()) {
		if (err) {
			console.log(chalk.bold.red('Physically unplug and reconnect your Particle devices and try again.'));
			return when.reject(err);
		}
		return when.resolve();
	}
	console.log(chalk.yellow('You are missing the permissions to access USB devices without root.'));
	return prompt({
		type: 'confirm',
		name: 'install',
		message: 'Would you like to install a udev rules file to get access?',
		default: true
	})
		.then(r => {
			if (!r.install) {
				if (err) {
					throw err;
				}
				throw new Error('Cancelled');
			}
			return installUdevRules();
		})
		.then(() => {
			console.log('udev rules installed.');
			if (err) {
				console.log(chalk.bold.red('Physically unplug and reconnect your Particle devices and try again.'));
				throw err;
			}
		});
}
381279
function udevRulesInstalled() {
	if (_udevRulesInstalled !== undefined) {
		return _udevRulesInstalled;
	}
	if (!systemSupportsUdev()) {
		_udevRulesInstalled = false;
		return false;
	}
	// Try to load the installed rules file
	let current = null;
	try {
		current = fs.readFileSync(UDEV_RULES_SYSTEM_FILE);
	} catch (e) {
		_udevRulesInstalled = false;
		return false;
	}
	// Compare the installed file with the file bundled with this app
	const latest = fs.readFileSync(UDEV_RULES_ASSET_FILE);
	_udevRulesInstalled = current.equals(latest);
	return _udevRulesInstalled;
}
39311
function errnoException(err, syscall, original) {
  // TODO(joyeecheung): We have to use the type-checked
  // getSystemErrorName(err) to guard against invalid arguments from users.
  // This can be replaced with [ code ] = errmap.get(err) when this method
  // is no longer exposed to user land.
  if (util === undefined) util = require('util');
  const code = util.getSystemErrorName(err);
  const message = original ?
    `${syscall} ${code} ${original}` : `${syscall} ${code}`;

  // eslint-disable-next-line no-restricted-syntax
  const ex = new Error(message);
  // TODO(joyeecheung): errno is supposed to err, like in uvException
  ex.code = ex.errno = code;
  ex.syscall = syscall;

  Error.captureStackTrace(ex, errnoException);
  return ex;
}
213282
function (err) {
    var status = typeof err === 'number' ? err : err.status;

    if (!(err instanceof errors.HTTPError) && status) {
      return errors.create(status, err.message);
    }
    return err;
  }
981098
function (err) {
        var message = {cmd: 'startupComplete', pid: process.pid};
        if (err) {
            console.warn(err.stack);
            message.error = err.message;
        }
        process.send(message);
    }
867859
function installRequirements(done) {
  var _calls = [];
  _.forEach(REQUIRED_INSTALLS, function(npmName) {
    _calls.push(function(done) {
      return Crux.util.install.npm(npmName, done, false);
    });
  });
  async.waterfall(_calls, done);
}
350962
function installVer(name, ver, dir) {
        var _child$spawnSync2 = _child_process2['default'].spawnSync(npmCommand, ['install', name + '@' + ver], { cwd: dir });

        var error = _child$spawnSync2.error;

        if (error) throw error;
    }
1263384
function(version) {
  var result;
  /** local */
  var ensure = function(key) {
    return function(r) {
      if (r && !r[key]) { throw new Error('result missing ' + key); }
      return r;
    };
  };
  return plugins.first(function(plugin) {
    return Promise.resolve()
    .then(function() { return plugin.match(version); })
    .then(ensure('command'))
    .then(ensure('version'))
    .then(function(r) { return (result = r); });
  })
  .then(function(plugin) {
    return result && _.extend({ plugin: plugin }, result);
  });
}
232077
function makePromise(fn) {
                    return new WinJS.Promise(function init(completeDispatch, errorDispatch) {
                        fn(function successCb(results) {
                            completeDispatch(results);
                        }, function errorCb(error) {
                            errorDispatch(error);
                        });
                    });
                }
1133473
function onOutgoingError(err) {
    if (cb) {
      cb(err, req, socket);
    } else {
      server.emit('error', err, req, socket);
    }
    socket.end();
  }
363290
function rejectHandler(err) {
  process.stderr.write(`${err.stack || err}\n`);

  if (sh.config.fatal) {
    sh.exit(1);
  }

  return Promise.reject(err);
}
1112104
function (def, err) {
    def.errors = def.errors || []
    err.message = err.message.cyan
    def.errors.push(err)
  }
908654
function (err) {
    "use strict";

    var message = '';

    if (typeof err === 'string') {
      return new Error(err);

    } else if (typeof err === 'object') {

      if (err.cause) {
        // probably a webdriver error
        try {
          message = JSON.parse(err.cause.value.message).errorMessage;
        } catch ($) {
          message = err.cause.value.message;
        }
      } else {
        message = err.message || err.toString();
      }
      return new Error(message);
    }
    return new Error(err.toString());
  }
480761
function formatError(error) {
        function localize(key) {
            if (Strings[key]) {
                return Strings[key];
            }
            console.log("Unknown installation error", key);
            return Strings.UNKNOWN_ERROR;
        }

        if (Array.isArray(error)) {
            error[0] = localize(error[0]);
            return StringUtils.format.apply(window, error);
        } else {
            return localize(error);
        }
    }
132742
function makeRequest(capturedError) {
      req(app)
        .get('/bundle.js')
        .expect(500)
        .end(function(err, res) {
          if (err) {
            done(err);
          }
          assert.ok(capturedError, 'expected error in onerror');
          assert.equal(res.text, capturedError.stack);
          done();
        });
    }
1321264
function oktaErrorTransformer(err) {
  if (err && err.errorCauses) {
    err.errorCauses.forEach(function (cause) {
      if (cause.errorSummary === 'login: An object with this field already exists in the current organization') {
        err.userMessage = 'An account with that email address already exists.';
      } else if (!err.userMessage) {
        // This clause allows the first error cause to be returned to the user
        err.userMessage = cause.errorSummary;
      }
    });
  }

  // For OAuth errors
  if (err && err.error_description) {
    err.message = err.error_description;
  }

  if (err && err.error === 'invalid_grant') {
    err.status = 400;
    err.code = 7104;
    err.message = 'Invalid username or password.';
  }

  return err;
}
1243516
function ensureDir(dir, mode, callback) {
    var deferred = Q.defer();

    if (mode && typeof mode === 'function') {
        callback = mode;
        mode = null;
    }

    mode = mode || parseInt('0777', 8) & (~process.umask());


    _ensureDir(dir, mode, function (err) {
        if (err) {
            deferred.reject(err);
        } else {
            deferred.resolve();
        }
    });

    return deferred.promise.nodeify(callback);
}