How to use the assert-plus.optionalBool function in assert-plus

To help you get started, we’ve selected a few assert-plus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github splunk / splunk-aws-project-trumpet / cloudtrail-serverless / lambda_code / cloudtrail_logger / node_modules / dashdash / lib / dashdash.js View on Github external
function Parser(config) {
    assert.object(config, 'config');
    assert.arrayOfObject(config.options, 'config.options');
    assert.optionalBool(config.interspersed, 'config.interspersed');
    var self = this;

    // Allow interspersed arguments (true by default).
    this.interspersed = (config.interspersed !== undefined
        ? config.interspersed : true);

    // Don't allow unknown flags (true by default).
    this.allowUnknown = (config.allowUnknown !== undefined
        ? config.allowUnknown : false);

    this.options = config.options.map(function (o) { return shallowCopy(o); });
    this.optionFromName = {};
    this.optionFromEnv = {};
    for (var i = 0; i < this.options.length; i++) {
        var o = this.options[i];
        if (o.group !== undefined && o.group !== null) {
github joyent / sdc-docker / test / lib / volumes.js View on Github external
function createTestFunc(options) {
    assert.object(options, 'options');
    assert.optionalBool(options.checkDockerClientSupportsNfsVols,
        'options.checkDockerClientSupportsNfsVols');
    assert.optionalBool(options.checkTritonSupportsNfsVols,
        'options.checkTritonSupportsNfsVols');

    var dockerClientSupportsVols =
        process.env.DOCKER_CLI_VERSION !== undefined
            && dockerClientSupportsVolumes(process.env.DOCKER_CLI_VERSION);

    return function testWrapper(testName, testFunc) {
        assert.string(testName, 'testName');
        assert.func(testFunc, 'testFunc');

        test(testName, function (t) {
            if (options.checkDockerClientSupportsNfsVols
                && !dockerClientSupportsVols) {
                t.ok(true,
                    'Docker client doesn\'t support volumes - skipping test');
                t.end();
github joyent / buildymcbuildface / lib / imgadm / lib / cli.js View on Github external
function listImagesInfo(imagesInfo, opts) {
    assert.arrayOfObject(imagesInfo, 'imagesInfo');
    assert.optionalObject(opts, 'opts');
    if (!opts) {
        opts = {};
    }
    assert.optionalBool(opts.json, 'opts.json');
    assert.optionalBool(opts.skipHeader, 'opts.skipHeader');
    assert.optionalBool(opts.docker, 'opts.docker');
    assert.optionalArrayOfString(opts.columns, 'opts.columns');
    assert.optionalArrayOfString(opts.sort, 'opts.sort');

    if (opts.json) {
        console.log(JSON.stringify(imagesInfo, null, 2));
    } else {
        var rows = imagesInfo.map(
            function (imageInfo) { return rowFromImageInfo(imageInfo); });

        /**
         * `docker images`-like output:
         * - only docker images
         * - one row per *tag*
         * - skip "non-head" images (see docker/graph/list.go)
github joyent / smartos-live / src / img / lib / cli.js View on Github external
function listImagesInfo(imagesInfo, opts) {
    assert.arrayOfObject(imagesInfo, 'imagesInfo');
    assert.optionalObject(opts, 'opts');
    if (!opts) {
        opts = {};
    }
    assert.optionalBool(opts.json, 'opts.json');
    assert.optionalBool(opts.skipHeader, 'opts.skipHeader');
    assert.optionalBool(opts.docker, 'opts.docker');
    assert.optionalArrayOfString(opts.columns, 'opts.columns');
    assert.optionalArrayOfString(opts.sort, 'opts.sort');

    if (opts.json) {
        console.log(JSON.stringify(imagesInfo, null, 2));
    } else {
        var rows = imagesInfo.map(
            function (imageInfo) { return rowFromImageInfo(imageInfo); });

        /**
         * `docker images`-like output:
         * - only docker images
         * - one row per *tag*
         * - skip "non-head" images (see docker/graph/list.go)
         */
        if (opts.docker) {
github joyent / smartos-live / src / fw / node_modules / cmdln / index.js View on Github external
self.helpSubcmds.forEach(function (sc) {
            if (typeof (sc) === 'object') {
                assert.string(sc.group, 'helpSubcmds.*.group');
                assert.optionalBool(sc.unmatched, 'helpSubcmds.*.unmatched');

                self._subcmdOrder.push(sc);

                if (sc.unmatched) {
                    if (++unmatchCount > 1) {
                        throw (new Error(format('"unmatched" directive used ' +
                            'more than once in "helpSubcmds" option: %j', sc)));
                    }

                    /*
                     * Include all of the unmatched names here:
                     */
                    while (unmatchedNames.length > 0) {
                        self._subcmdOrder.push(unmatchedNames.shift());
                    }
                }
github joyent / smartos-live / src / img / node_modules / sdc-clients / lib / imgapi.js View on Github external
function adminImportRemoteImage(uuid, source, options, callback) {
    var self = this;
    if (callback === undefined) {
        callback = options;
        options = {};
    }
    assert.string(uuid, 'uuid');
    assert.string(source, 'source');
    assert.object(options, 'options');
    assert.optionalBool(options.skipOwnerCheck, 'options.skipOwnerCheck');
    assert.optionalObject(options.headers, 'options.headers');
    assert.func(callback, 'callback');

    var path = self._path('/images/' + uuid, {
        channel: self.channel,
        action: 'import-remote',
        source: source,
        skip_owner_check: options.skipOwnerCheck
    });
    self._getAuthHeaders(function (hErr, headers) {
        if (hErr) {
            callback(hErr);
            return;
        }
        if (options.headers) {
            simpleMerge(headers, options.headers);
github joyent / sdc-docker / lib / backends / sdc / containers.js View on Github external
function _createLinestreamParser(opts, toSocket) {
    assert.object(opts, 'opts');
    assert.object(opts.log, 'opts.log');
    assert.object(opts.socketData, 'opts.socketData');
    assert.optionalBool(opts.doNotEncodeData, 'doNotEncodeData');
    assert.object(toSocket, 'toSocket');

    var encodeData = !(opts.doNotEncodeData);
    var lstream = new LineStream({ encoding: 'utf8' });
    lstream.on('error', function (err) {
        opts.log.error({ err: err }, 'LineStream threw an error');
    });

    lstream.on('line', function (line) {
        line = line.trim();
        if (!line) {
            return;
        }

        var parsed = JSON.parse(line);
github joyent / sdc-docker / lib / backends / sdc / containers.js View on Github external
function _runAttach(opts, callback) {
    assert.object(opts, 'opts');
    assert.object(opts.app, 'opts.app');
    assert.optionalBool(opts.doNotEncodeData, 'doNotEncodeData');
    assert.optionalString(opts.id, 'opts.id');
    assert.object(opts.log, 'opts.log');
    assert.object(opts.socketData, 'opts.socketData');
    assert.object(opts.socket, 'opts.socket');

    var socketData = opts.socketData;
    var host = socketData.host;
    var port = socketData.port;
    var clientSocket = opts.socket;

    var cmdString = socketData.command.Cmd.join(' ');

    var serverSocket = socketData.socket;
    if (!serverSocket) {
        serverSocket = net.createConnection({ host: host, port: port });
        serverSocket.on('connect', setupListeners);
github joyent / smartos-live / src / img / node_modules / sdc-clients / lib / imgapi.js View on Github external
if (typeof (account) === 'function') {
        callback = account;
        options = {};
        account = undefined;
    } else if (typeof (account) === 'object') {
        callback = options;
        options = account;
        account = undefined;
    } else if (typeof (options) === 'function') {
        callback = options;
        options = {};
    }
    assert.optionalString(account, 'account');
    assert.object(options, 'options');
    assert.optionalObject(options.headers, 'options.headers');
    assert.optionalBool(options.forceAllChannels, 'options.forceAllChannels');
    assert.func(callback, 'callback');

    var path = self._path(format('/images/%s', uuid), {
        channel: self.channel,
        account: account,
        force_all_channels: options.forceAllChannels
    });
    self._getAuthHeaders(function (hErr, headers) {
        if (hErr) {
            callback(hErr);
            return;
        }
        if (!headers['content-length']) {
            headers['content-length'] = 0;
        }
        if (options.headers) {