From 898eb91cbb3dc32c240c4f53437c5c30ace5bdbb Mon Sep 17 00:00:00 2001 From: zkochan Date: Sun, 15 Jan 2017 01:54:00 +0200 Subject: [PATCH] feat(bin): add CLI --- package.json | 3 +++ src/bin/pnpm-reporter-default.ts | 9 +++++++++ tsconfig.json | 1 + typings/local.d.ts | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 src/bin/pnpm-reporter-default.ts diff --git a/package.json b/package.json index 8a57502b32..7267ecee25 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "files": [ "lib" ], + "bin": "lib/bin/pnpm-reporter-default.js", "scripts": { "test": "tslint -c tslint.json --project .", "tsc": "rimraf lib && tsc", @@ -27,7 +28,9 @@ "homepage": "https://github.com/pnpm/pnpm-reporter-default#readme", "dependencies": { "@types/chalk": "^0.4.31", + "@types/node": "^7.0.0", "chalk": "^1.1.3", + "ndjson": "^1.5.0", "observatory": "^1.0.0", "pnpm-logger": "^0.0.0" }, diff --git a/src/bin/pnpm-reporter-default.ts b/src/bin/pnpm-reporter-default.ts new file mode 100644 index 0000000000..4f6710b3f4 --- /dev/null +++ b/src/bin/pnpm-reporter-default.ts @@ -0,0 +1,9 @@ +#!/usr/bin/env node +import ndjson = require('ndjson') +import reporter from '..' + +process.stdin.resume() +process.stdin.setEncoding('utf8') +const streamParser = process.stdin + .pipe(ndjson.parse()) +reporter(streamParser) diff --git a/tsconfig.json b/tsconfig.json index 0308a05233..ca474dbf93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,7 @@ "rewriteTsconfig": true }, "files": [ + "src/bin/pnpm-reporter-default.ts", "src/index.ts", "typings/index.d.ts", "typings/local.d.ts" diff --git a/typings/local.d.ts b/typings/local.d.ts index b42e87f784..71733fbb68 100644 --- a/typings/local.d.ts +++ b/typings/local.d.ts @@ -2,3 +2,8 @@ declare module 'observatory' { const anything: any; export = anything; } + +declare module 'ndjson' { + const anything: any; + export = anything; +}