Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "nyks", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "nodejs exupery style", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
'use strict'; | ||
module.exports = { | ||
'parseargs' : require('./process/parseargs') | ||
'parseArgs' : require('./process/parseArgs'), | ||
'splitArgs' : require('./process/splitArgs'), | ||
}; | ||
@@ -25,6 +25,12 @@ nyks provide a set of "missing" stuffs in nodejs basic api. | ||
Return a hex encoded md5 hash | ||
* require('util').parseargs(process.argv.splice(2)) | ||
## process | ||
* require('nyks/process/parseArgs')(process.argv.splice(2)) | ||
Command line args parser, aligned on yks patterns | ||
* require('nyks/process/splitArgs')("some string 'with escaped' content") | ||
Split a string into whitespace separated chunks | ||
## fs | ||
@@ -31,0 +37,0 @@ * require('nyks/fs/deleteFolderRecursive')(path); |
"use strict"; | ||
var expect = require('expect.js') | ||
var parseargs = require('../process/parseargs') | ||
var parseArgs = require('../process/parseArgs') | ||
var splitArgs = require('../process/splitArgs') | ||
@@ -12,9 +13,9 @@ | ||
it("testing parseargs", function(){ | ||
expect(parseargs(["--foo"]) ).to.eql({args : [], dict : {foo:true}}); | ||
expect(parseargs(["--foo", "bar"]) ).to.eql({args : ["bar"], dict : {foo:true}}); | ||
expect(parseargs(["bar", "--foo"]) ).to.eql({args : ["bar"], dict : {foo:true}}); | ||
expect(parseargs(["bar", "--foo", "baz"]) ).to.eql({args : ["bar", "baz"], dict : {foo:true}}); | ||
expect(parseargs(["--foo=42", "--foo=55"]) ).to.eql({args : [], dict : {foo:[42, 55]}}); | ||
expect(parseargs(["--foo=42", "--foo=55", "--foo"]) ).to.eql({args : [], dict : {foo:[42, 55, true]}}); | ||
it("testing parseArgs", function(){ | ||
expect(parseArgs(["--foo"]) ).to.eql({args : [], dict : {foo:true}}); | ||
expect(parseArgs(["--foo", "bar"]) ).to.eql({args : ["bar"], dict : {foo:true}}); | ||
expect(parseArgs(["bar", "--foo"]) ).to.eql({args : ["bar"], dict : {foo:true}}); | ||
expect(parseArgs(["bar", "--foo", "baz"]) ).to.eql({args : ["bar", "baz"], dict : {foo:true}}); | ||
expect(parseArgs(["--foo=42", "--foo=55"]) ).to.eql({args : [], dict : {foo:[42, 55]}}); | ||
expect(parseArgs(["--foo=42", "--foo=55", "--foo"]) ).to.eql({args : [], dict : {foo:[42, 55, true]}}); | ||
}); | ||
@@ -26,6 +27,21 @@ | ||
it("should drop invalid args", function(){ | ||
expect(parseargs(["-=foo", "bar"]) ).to.eql({args : ["bar"], dict : {}}); | ||
expect(parseArgs(["-=foo", "bar"]) ).to.eql({args : ["bar"], dict : {}}); | ||
}); | ||
it("should test splitArgs", function(){ | ||
expect(splitArgs("a b c d") ).to.eql(["a", "b", "c", "d"]); | ||
expect(splitArgs("a 'b' c d") ).to.eql(["a", "b", "c", "d"]); | ||
expect(splitArgs("a \"b\" c d") ).to.eql(["a", "b", "c", "d"]); | ||
expect(splitArgs("a \"'b'\" c d") ).to.eql(["a", "'b'", "c", "d"]); | ||
expect(splitArgs("a \"'b c'\" c d") ).to.eql(["a", "'b c'", "c", "d"]); | ||
expect(splitArgs("a 'b c' c d") ).to.eql(["a", "b c", "c", "d"]); | ||
expect(splitArgs("") ).to.eql([]); | ||
expect(splitArgs("'foo''foobar'") ).to.eql(["foo"]); | ||
expect(splitArgs("'foo'foobar'") ).to.eql(["foo"]); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33095
62
868
106