Skip to content

Commit

Permalink
Hyphenate parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane committed Sep 23, 2016
1 parent bd6453f commit 4956d8b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 46 deletions.
80 changes: 40 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "clime",
"version": "0.4.1",
"description": "The command-line interface framework for TypeScript.",
"main": "bld/index.js",
"typings": "bld/index.d.ts",
"scripts": {
"test": "mocha",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vilic/clime.git"
},
"keywords": [
"typescript",
"command",
"cli",
"commander",
"commander.js"
],
"author": "vilicvane",
"license": "MIT",
"bugs": {
"url": "https://github.com/vilic/clime/issues"
},
"homepage": "https://github.com/vilic/clime#readme",
"dependencies": {
"chalk": "^1.1.1",
"extendable-error": "^0.1.2",
"hyphenate": "^0.2.1",
"reflect-metadata": "^0.1.3",
"villa": "^0.2.0"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"mocha": "^3.0.2",
"source-map-support": "^0.4.0",
"typescript": "^2.0.2"
}
"name": "clime",
"version": "0.4.2",
"description": "The command-line interface framework for TypeScript.",
"main": "bld/index.js",
"typings": "bld/index.d.ts",
"scripts": {
"test": "mocha",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vilic/clime.git"
},
"keywords": [
"typescript",
"command",
"cli",
"commander",
"commander.js"
],
"author": "vilicvane",
"license": "MIT",
"bugs": {
"url": "https://github.com/vilic/clime/issues"
},
"homepage": "https://github.com/vilic/clime#readme",
"dependencies": {
"chalk": "^1.1.1",
"extendable-error": "^0.1.2",
"hyphenate": "^0.2.1",
"reflect-metadata": "^0.1.3",
"villa": "^0.2.0"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"mocha": "^3.0.2",
"source-map-support": "^0.4.0",
"typescript": "^2.0.3"
}
}
8 changes: 5 additions & 3 deletions src/core/command/param.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as assert from 'assert';

import hyphenate from 'hyphenate';

import {
Command,
GeneralValidator
Expand Down Expand Up @@ -63,8 +65,7 @@ export function param<T>(
description
}: ParamOptions<T> = {}
) {
// TODO: name: 'execute'
return (target: Command, name: string, index: number) => {
return (target: Command, name: 'execute', index: number) => {
assert.equal(name, 'execute');

let constructor = target.constructor as typeof Command;
Expand All @@ -80,7 +81,8 @@ export function param<T>(
type = type ||
Reflect.getMetadata('design:paramtypes', target, 'execute')[index] as Clime.Constructor<T>;

paramName = paramName || Reflection.getFunctionParameterName(target.execute, index);
paramName = paramName ||
hyphenate(Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true });

if (!validators) {
validators = validator ? [validator] : [];
Expand Down
8 changes: 5 additions & 3 deletions src/core/command/params.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as assert from 'assert';

import hyphenate from 'hyphenate';

import {
Command,
GeneralValidator
Expand Down Expand Up @@ -59,8 +61,7 @@ export function params<T>(
description
}: ParamsOptions<T>
) {
// TODO: name: 'execute'
return (target: Command, name: string, index: number) => {
return (target: Command, name: 'execute', index: number) => {
assert.equal(name, 'execute');

let constructor = target.constructor as typeof Command;
Expand All @@ -74,7 +75,8 @@ export function params<T>(
type = type ||
Reflect.getMetadata('design:paramtypes', target, 'execute')[index] as Clime.Constructor<T>;

paramName = paramName || Reflection.getFunctionParameterName(target.execute, index);
paramName = paramName ||
hyphenate(Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true });

if (!validators) {
validators = validator ? [validator] : [];
Expand Down

0 comments on commit 4956d8b

Please sign in to comment.