Skip to content

screwdriver-cd/command-validator

Repository files navigation

command-validator

Version Downloads Build Status Open Issues Dependency Status License

A module for validating a Screwdriver Command file

YAML

# example.yaml
namespace: git
name: clone
version: '1.1'
description: SD Command for git clone with habitat.
maintainer: example@gmail.com
format: habitat
habitat:
    mode: remote
    package: core/git/2.14.1
    command:  git clone

Usage

$ npm install screwdriver-command-validator

Validate in Node.js:

const fs = require('fs');  // standard fs module
const validator = require('screwdriver-command-validator');

// The "example.yaml" is the YAML described above
validator(fs.readFileSync('example.yaml'))
    .then((commandData) => {
        console.log(commandData);
    });

Output of the console.log():

config: {
    description: 'SD Command for git clone with habitat.',
    maintainer: 'example@gmail.com',
    name: 'git',
    namespace: 'clone',
    version: '1.0',
    format: 'habitat',
    habitat: {
        mode: 'remote',
        package: 'core/git/2.14.1',
        command: 'git clone'
    }
}

Validate in CLI:

$ ./node_modules/.bin/command-validate -h

  Usage: validate [options]


  Options:

    -j, --json         output with JSON
    -f, --file [name]  screwdriver command file (default: ./sd-command.yaml)
    -h, --help         output usage information

$ ./node_modules/.bin/command-validate -j
{"valid":true}

Testing

npm test

License

Code licensed under the BSD 3-Clause license. See LICENSE file for terms.