Skip to content

Commit

Permalink
fix: few fixes before releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Jan 9, 2019
1 parent 7bda226 commit 4b30ad6
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 36 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -2,9 +2,9 @@
"name": "@pm2/io",
"version": "2.4.7",
"description": "PM2.io NodeJS APM",
"main": "build/main/src/index.js",
"typings": "build/main/src/index.d.ts",
"types": "build/main/src/index.d.ts",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
"types": "build/main/index.d.ts",
"module": "build/module/index.js",
"repository": "https://github.com/keymetrics/pm2-io-apm",
"author": {
Expand Down
11 changes: 7 additions & 4 deletions src/configuration.ts
Expand Up @@ -7,9 +7,6 @@ import * as path from 'path'
import * as fs from 'fs'
import * as util from 'util'

const prefix = __dirname.replace(/\\/g,'/').indexOf('/build/') >= 0 ? '../../../' : '../'
const pkg = require(prefix + '/package.json')

export default class Configuration {

static configureModule (opts) {
Expand Down Expand Up @@ -49,7 +46,13 @@ export default class Configuration {
if (!conf.module_conf) {
conf.module_conf = {}
}
conf.pmx_version = pkg.version || null

try {
const pkg = require('../package.json')
conf.pmx_version = pkg.version || null
} catch (err) {
// ignore
}

if (conf.isModule === true) {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -7,4 +7,4 @@ const isAlreadyHere = (Object.getOwnPropertySymbols(global).indexOf(IO_KEY) > -1
const io: PMX = isAlreadyHere ? global[IO_KEY] as PMX : new PMX().init()
global[IO_KEY] = io

export default io
export = io
4 changes: 2 additions & 2 deletions src/metrics/httpMetrics.ts
Expand Up @@ -184,10 +184,10 @@ export default class HttpMetrics implements MetricInterface {
// we first require the target module
const returned = original.apply(original, arguments)
// if it's a modue that we want to patch, install the patch on top of it
if (file === 'http') {
if (file === 'http' && self.modules['http'] === undefined) {
self.registerHttpMetric()
self.hookHttp(returned, file)
} else if (file === 'https') {
} else if (file === 'https' && self.modules['https'] === undefined) {
self.registerHttpsMetric()
self.hookHttp(returned, file)
}
Expand Down
2 changes: 1 addition & 1 deletion test/api.spec.ts
Expand Up @@ -5,7 +5,7 @@ import * as semver from 'semver'
import { resolve } from 'path'

import { exec, fork } from 'child_process'
import pmx from '../src'
import * as pmx from '../src'

const launch = (fixture) => {
return fork(resolve(__dirname, fixture), [], {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiActionsChild.ts
@@ -1,4 +1,4 @@
import pmx from '../../src'
import * as pmx from '../../src'

pmx.action('testAction', function (reply) {
reply({ data: 'testActionReply' })
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiActionsJsonChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

// @ts-ignore
pmx.action({
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiBackwardActionsChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

pmx.init({
actions: {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiBackwardConfChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'
let timer
let server

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiBackwardEventChild.ts
@@ -1,4 +1,4 @@

import pmx from '../../src'
import * as pmx from '../../src'

pmx.emit('myEvent', { prop1: 'value1' })
2 changes: 1 addition & 1 deletion test/fixtures/apiBackwardExpressChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

const express = require('express')
const app = express()
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiInitModuleChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

process.env.fixtures = JSON.stringify({
envVar: 'value',
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiKoaErrorHandler.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

const Koa = require('koa')
const app = new Koa()
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiMetricsChild.ts
@@ -1,5 +1,5 @@

import io from '../../src'
import * as io from '../../src'
import { MetricType } from '../../src/services/metrics'

const [ one, two, three ] = io.metrics(
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiNotifyChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src/index'
import * as pmx from '../../src/index'

pmx.init()
pmx.notifyError(new Error('myNotify'))
2 changes: 1 addition & 1 deletion test/fixtures/apiOnExitChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

pmx.onExit(function () {
if (process && process.send) process.send('callback')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apiOnExitExceptionChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../src'
import * as pmx from '../../src'

pmx.onExit(function () {
if (process && process.send) process.send('callback')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/autoExitChild.ts
@@ -1,4 +1,4 @@

import io from '../../src'
import * as io from '../../src'

io.init()
2 changes: 1 addition & 1 deletion test/fixtures/features/eventLoopInspectorChild.ts
@@ -1,4 +1,4 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
actions: {
eventLoopDump: true
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/features/eventsChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../../src'
import * as pmx from '../../../src'

pmx.init({
profiling: true
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/features/profilingChild.ts
@@ -1,5 +1,5 @@

import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
profiling: true
})
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/metrics/gcv8Child.ts
@@ -1,4 +1,4 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
metrics: {
eventLoop: true,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/metrics/httpWrapperChild.ts
@@ -1,4 +1,4 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
metrics: {
eventLoop: true,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/metrics/networkChild.ts
@@ -1,4 +1,4 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
metrics: {
eventLoop: true,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/metrics/networkWithoutDownloadChild.ts
@@ -1,4 +1,4 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
metrics: {
network: {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/metrics/tracingChild.ts
@@ -1,8 +1,9 @@
import pmx from '../../../src'
import * as pmx from '../../../src'
pmx.init({
tracing: true
})

// @ts-ignore added in ci only
import * as express from 'express'
const app = express()

Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Expand Up @@ -11,17 +11,16 @@
"inlineSourceMap": true,
"traceResolution": false,
"downlevelIteration": true,
"resolveJsonModule": true,
"removeComments": true,
"lib" : [
"es6"
],
"types": [
"node",
"mocha"
],
"baseUrl": ".", // required for "paths"
"paths": {
"pmx-2": ["src/index.ts"] // write tests without relative paths
}
"baseUrl": "." // required for "paths"
},
"include": [
"src/**/*.ts"
Expand Down

0 comments on commit 4b30ad6

Please sign in to comment.