'use strict';

var getos = require('getos');
var execFile = require('child_process').execFile;

/**
 * Get the current Linux distro
 *
 * @param {Function} cb
 * @api public
 */

module.exports = function (cb) {
	if (process.platform !== 'linux') {
		cb(new Error('Only Linux systems are supported'));
		return;
	}

	execFile('lsb_release', ['-a', '--short'], function (err, stdout) {
		var obj = {};

		if (err) {
			getos(function (err, res) {
				if (err) {
					cb(err);
					return;
				}

				cb(null, { os: res });
			});
		}

		stdout = stdout.split('\n');

		obj.os = stdout[0];
		obj.name = stdout[1];
		obj.release = stdout[2];
		obj.code = stdout[3];

		cb(null, obj);
	});
};

'use strict';

var getos = require('getos');
var execFile = require('child_process').execFile;

/**
 * Get the current Linux distro
 *
 * @param {Function} cb
 * @api public
 */

module.exports = function (cb) {
	if (process.platform !== 'linux') {
		throw new Error('Only Linux systems are supported');
	}

	execFile('lsb_release', ['-a', '--short'], function (err, stdout) {
		var obj = {};

		if (err) {
			getos(function (err, res) {
				if (err) {
					cb(err);
					return;
				}

				cb(null, { os: res });
			});
		}

		stdout = stdout.split('\n');

		obj.os = stdout[0];
		obj.name = stdout[1];
		obj.release = stdout[2];
		obj.code = stdout[3];

		cb(null, obj);
	});
};

Throw instead of returning an error
Throw instead of returning an error
