Skip to content

Commit

Permalink
[refactor] Not to use pkginfo package to extract "version" in package…
Browse files Browse the repository at this point in the history
….json
  • Loading branch information
nwtgck committed Jan 29, 2019
1 parent 9e9993f commit 84280cd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/dist
/src/version.ts

/ssl_certs
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"main": "dist/src/piping.js",
"types": "dist/src/piping.d.ts",
"scripts": {
"build": "tsc",
"generate-version": "echo \"export const VERSION = \\\"$npm_package_version\\\";\" > src/version.ts",
"build": "npm run generate-version && tsc",
"start": "npm run build && node dist/src/index.js",
"lint": "tslint 'src/**/*.ts' && tslint 'test/**/*.ts'",
"prepare": "npm run build",
Expand Down Expand Up @@ -37,6 +38,7 @@
"espower-typescript": "^9.0.0",
"get-port": "^4.0.0",
"mocha": "^5.0.5",
"pkginfo": "^0.4.1",
"power-assert": "^1.4.4",
"request": "^2.88.0",
"then-request": "^6.0.0",
Expand All @@ -46,7 +48,6 @@
},
"dependencies": {
"multiparty": "^4.2.1",
"pkginfo": "^0.4.1",
"yargs": "^12.0.2"
}
}
9 changes: 1 addition & 8 deletions src/piping.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import * as http from "http";
import * as multiparty from "multiparty";
import * as pkginfo from "pkginfo";
import {ParsedUrlQuery} from "querystring";
import * as stream from "stream";
import * as url from "url";

import * as path from "path";
import {opt, optMap} from "./utils";

// Set module.exports.version
pkginfo(module, "version");

// Get version
// (from: https://stackoverflow.com/a/22339262/2885946)
const VERSION: string = module.exports.version;
import {VERSION} from "./version";

type ReqRes = {
readonly req: http.IncomingMessage,
Expand Down

0 comments on commit 84280cd

Please sign in to comment.