Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 9c95aa0

Browse files
authored
Remove deprecated @types/pkg-dir and pkg-dir (#438)
* Remove deprecated @types/pkg-dir and update pkg-dir to v4 * Fix build -> Remove pkg-dir as it is not supported for node 6
1 parent 234c395 commit 9c95aa0

File tree

6 files changed

+21
-32
lines changed

6 files changed

+21
-32
lines changed

packages/opencensus-exporter-zpages/package-lock.json

+9-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-exporter-zpages/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"@types/extend": "^3.0.0",
4747
"@types/mocha": "^5.2.5",
4848
"@types/node": "^10.12.12",
49-
"@types/pkg-dir": "^2.0.0",
5049
"axios": "^0.18.0",
5150
"codecov": "^3.1.0",
5251
"gts": "^0.9.0",
@@ -59,7 +58,6 @@
5958
"dependencies": {
6059
"@opencensus/core": "^0.0.9",
6160
"ejs": "^2.5.8",
62-
"express": "^4.16.3",
63-
"pkg-dir": "^3.0.0"
61+
"express": "^4.16.3"
6462
}
6563
}

packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/rpcz.page-handler.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
*/
1616

1717
import {AggregationType} from '@opencensus/core';
18+
import * as ejs from 'ejs';
19+
import * as path from 'path';
1820
import {StatsParams} from '../../zpages';
1921

20-
const ejs = require('ejs');
21-
22-
import * as pkgDir from 'pkg-dir';
23-
const templatesDir = `${pkgDir.sync(__dirname)}/templates`;
24-
22+
const templatesDir = path.join(__dirname, '../../../../templates');
2523
const FIXED_SIZE = 3;
2624

2725
export interface ZMeasureOrders {
@@ -71,8 +69,7 @@ export class RpczPageHandler {
7169
*/
7270
emitHtml(json: boolean): string {
7371
/** template HTML */
74-
const rpczFile =
75-
ejs.fileLoader(`${templatesDir}/rpcz.ejs`, 'utf8').toString();
72+
const rpczFile = ejs.fileLoader(`${templatesDir}/rpcz.ejs`).toString();
7673
/** CSS styles file */
7774
const stylesFile =
7875
ejs.fileLoader(`${templatesDir}/styles.min.css`).toString();

packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/statsz.page-handler.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
import {AggregationData, AggregationType, TagKey, TagValue, View} from '@opencensus/core';
1818
import {StatsParams} from '../../zpages';
19-
2019
const ejs = require('ejs');
2120

22-
import * as pkgDir from 'pkg-dir';
21+
import * as path from 'path';
2322

2423
export interface StatszParams {
2524
path: string;
@@ -202,7 +201,7 @@ export class StatszPageHandler {
202201
* file
203202
*/
204203
private loaderFile(fileName: string): string {
205-
const rootDir = `${pkgDir.sync(__dirname)}`;
206-
return ejs.fileLoader(`${rootDir}/templates/${fileName}`, 'utf8');
204+
const fileDir = path.join(__dirname, '../../../../templates', fileName);
205+
return ejs.fileLoader(fileDir, 'utf8');
207206
}
208207
}

packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/traceconfigz.page-handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import {SamplerBuilder} from '@opencensus/core';
1818
import * as tracing from '@opencensus/nodejs';
1919
import * as ejs from 'ejs';
20-
import * as pkgDir from 'pkg-dir';
20+
import * as path from 'path';
2121

2222
// The directory to search for templates.
23-
const templatesDir = `${pkgDir.sync(__dirname)}/templates`;
23+
const templatesDir = path.join(__dirname, '../../../../templates');
2424

2525
export interface TraceConfigzParams {
2626
change: string;

packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/tracez.page-handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
import {RootSpan, Span} from '@opencensus/core';
1818
import * as ejs from 'ejs';
19-
import * as pkgDir from 'pkg-dir';
19+
import * as path from 'path';
2020

2121
import {LatencyBucketBoundaries} from '../latency-bucket-boundaries';
2222

2323
// The directory to search for templates.
24-
const templatesDir = `${pkgDir.sync(__dirname)}/templates`;
24+
const templatesDir = path.join(__dirname, '../../../../templates');
2525

2626
export type TracezParams = {
2727
tracename: string; type: string;

0 commit comments

Comments
 (0)