diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..dbb046f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,55 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + - build: + docker: + # specify the version you desire here + - image: circleci/node:10.4.1 + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/mongo:3.4.4 + + working_directory: ~/repos + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: npm ci + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + # run tests! + - run: npm test + + - publish: + docker: + - image: circleci/node:10.4.1 + steps: + - checkout + - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + - run: npm publish + +workflows: + version: 2 + tagged-build: + jobs: + - publish: + filters: + tags: + only: /v[0-9]+(\.[0-9]+)*/ + diff --git a/.gitignore b/.gitignore index 9966bde..41be75c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.idea +.vscode + dist/ node_modules npm-debug.log diff --git a/.travis.yml b/.travis.yml index b3ad2b8..bc548f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: node_js node_js: - - 9.11.1 + - 10.4.1 cache: directories: - "$HOME/.npm" diff --git a/package.json b/package.json index aefc183..ebc2509 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commander-ts", - "version": "0.1.4", + "version": "0.1.5", "description": "TypeScript decorators that enhance commander", "keywords": [ "command line", @@ -13,6 +13,7 @@ "scripts": { "prebuild": "rimraf dist", "build": "tsc", + "exec": "node dist/program.js", "test": "echo \"No tests yet\"" }, "author": { diff --git a/src/decorators/command.decorator.ts b/src/decorators/command.decorator.ts index 223902d..90796a9 100644 --- a/src/decorators/command.decorator.ts +++ b/src/decorators/command.decorator.ts @@ -26,7 +26,7 @@ export function command(): MethodDecorator { const cmdArgs = args.slice(0, args.length - 1); try { - const result = target[propertyKey].apply(target, cmdArgs); + const result = target[propertyKey].apply(context, cmdArgs); if (result instanceof Promise) { await result; diff --git a/src/program.ts b/src/program.ts index bf16973..938bacb 100644 --- a/src/program.ts +++ b/src/program.ts @@ -10,7 +10,7 @@ import { @description('A basic program') @usage('--help') export class Program { - @option('--env <env>') + @option('--env <env>', 'Set the environment') env: string = null; constructor() {} diff --git a/tslint.json b/tslint.json index ff47a74..8b3460e 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,5 @@ { - "rulesDirectory": [ - "node_modules/codelyzer" - ], + "rulesDirectory": [], "rules": { "arrow-return-shorthand": true, "callable-types": true,