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

Commit

Permalink
Don't copy package.json to build directory
Browse files Browse the repository at this point in the history
We do not need to handle two relative paths because both the packaged
lib and test suite run through the /build directory, which means we
can support a single path.

The opencensus-exporter-ocagent has been updated to support the newly
exported version.
  • Loading branch information
Justin Smith committed Nov 20, 2018
1 parent b58ec5a commit 4212361
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/opencensus-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": "nyc -x '**/test/**' --reporter=html --reporter=text mocha 'build/test/**/*.js'",
"clean": "rimraf build/*",
"check": "gts check",
"compile": "tsc -p . && cp package.json build/",
"compile": "tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile",
"pretest": "npm run compile",
Expand Down
11 changes: 10 additions & 1 deletion packages/opencensus-core/src/common/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@
* limitations under the License.
*/

const pjson = require('../../package.json');
type Package = {
version: string;
};

// Load the package details. Note that the `require` is performed at runtime,
// which means the source files will be in the `/build` directory, so the
// package path is relative to that location.
const pjson: Package = require('../../../package.json');

// Export the core package version
export const version: string = pjson.version;
5 changes: 2 additions & 3 deletions packages/opencensus-exporter-ocagent/src/ocagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as protoLoader from '@grpc/proto-loader';
import {Exporter, ExporterBuffer, ExporterConfig, logger, Logger, RootSpan, SamplerBuilder} from '@opencensus/core';
import {Exporter, ExporterBuffer, ExporterConfig, logger, Logger, RootSpan, SamplerBuilder, version as coreVersion} from '@opencensus/core';
import * as tracing from '@opencensus/nodejs';
import * as grpc from 'grpc';
import * as os from 'os';
Expand Down Expand Up @@ -91,8 +91,7 @@ export class OCAgentExporter implements Exporter {
* Get node properties
*/
this.exporterVersion = require('../../package.json').version;
this.coreVersion =
require('../../node_modules/@opencensus/core/package.json').version;
this.coreVersion = coreVersion;
this.hostName = os.hostname();
this.processStartTimeMillis = Date.now() - (process.uptime() * 1000);

Expand Down

0 comments on commit 4212361

Please sign in to comment.