index.js
function split( command ) {
    if ( typeof command !== 'string' ) {
        throw new Error( 'Command must be a string' );
    }

    var r = command.match( /[^"\s]+|"(?:\\"|[^"])*"/g );
    if ( ! r ) {
        return [];
    }

    return r.map( function ( expr ) {
        var isQuoted = expr.charAt( 0 ) === '"' && expr.charAt( expr.length - 1 ) === '"';
        return isQuoted ? expr.slice( 1, -1 ) : expr;
    } );
}
function split( command ) {
    if ( typeof command !== 'string' ) {
        throw new Error( 'Command must be a string' );
    }

    var r = command.match( /[^"\s]+|"(?:\\"|[^"])*"/g );
    if ( ! r ) {
        return [];
    }

    return r.map( function ( expr ) {
        var isQuoted = expr.charAt( 0 ) === '"' && expr.charAt( expr.length - 1 ) === '"';
        return isQuoted ? expr.slice( 1, -1 ) : expr;
    } );
}
function split ( command ) { if ( typeof command !== 'string' ) { throw new Error ( 'Command must be a string' ) ; } var r = command . match ( / [^"\s]+|"(?:\\"|[^"])*" / g ) ; if ( ! r ) { return [ ] ; } return r . map ( function ( expr ) { var isQuoted = expr . charAt ( 0 ) === '"' && expr . charAt ( expr . length - 1 ) === '"' ; return isQuoted ? expr . slice ( 1 , - 1 ) : expr ; } ) ; }
Split a command into an array.

@example
```js
var arr = split( 'git commit -m "some message with spaces"' );
console.log( arr ); // [ "git", "commit", "-m", "some message with spaces" ]
```

@param {string} command Command to split.
@returns {Array}
Split a command into an array .