You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/11/15 11:00:46 UTC

[GitHub] [skywalking-nodejs] tom-pytel commented on a diff in pull request #102: Update AxiosPlugin for v1.0+

tom-pytel commented on code in PR #102:
URL: https://github.com/apache/skywalking-nodejs/pull/102#discussion_r1022647753


##########
src/plugins/AxiosPlugin.ts:
##########
@@ -26,20 +26,39 @@ import { SpanLayer } from '../proto/language-agent/Tracing_pb';
 import DummySpan from '../trace/span/DummySpan';
 import { ignoreHttpMethodCheck } from '../config/AgentConfig';
 import PluginInstaller from '../core/PluginInstaller';
+import * as fs from 'fs';
+import * as path from 'path';
 
 class AxiosPlugin implements SwPlugin {
   readonly module = 'axios';
   readonly versions = '*';
 
+  getVersion(installer: PluginInstaller): string {
+    // TODO: this method will not work in a bundle
+    try {
+      const indexPath = installer.resolve(this.module);
+      const dirname = indexPath.slice(
+        0,
+        indexPath.lastIndexOf(`${path.sep}node_modules${path.sep}axios${path.sep}`) + 20,
+      );
+      const packageSJonStr = fs.readFileSync(`${dirname}package.json`, { encoding: 'utf-8' });
+      const pkg = JSON.parse(packageSJonStr);

Review Comment:
   🥇 :|



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org