File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " serverless-plugin-datadog" ,
3- "version" : " 0.8 .0" ,
3+ "version" : " 0.9 .0" ,
44 "description" : " Serverless plugin to automatically instrument python and node functions with datadog tracing" ,
55 "main" : " dist/index.js" ,
66 "repository" : " https://github.com/DataDog/serverless-plugin-datadog" ,
Original file line number Diff line number Diff line change 1+ import { pythonTemplate } from "./python-template" ;
2+
3+ describe ( "pythonTemplate" , ( ) => {
4+ it ( "handles nested directories" , ( ) => {
5+ const result = pythonTemplate ( "my/file/path" , "method" ) ;
6+ expect ( result ) . toMatchInlineSnapshot ( `
7+ "from datadog_lambda.wrapper import datadog_lambda_wrapper
8+ from my.file.path import method as method_impl
9+ method = datadog_lambda_wrapper(method_impl)"
10+ ` ) ;
11+ } ) ;
12+ it ( "handles windows directories" , ( ) => {
13+ const result = pythonTemplate ( `my\\file\\path` , "method" ) ;
14+ expect ( result ) . toMatchInlineSnapshot ( `
15+ "from datadog_lambda.wrapper import datadog_lambda_wrapper
16+ from my.file.path import method as method_impl
17+ method = datadog_lambda_wrapper(method_impl)"
18+ ` ) ;
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 77 */
88
99export function pythonTemplate ( filePath : string , method : string ) {
10- const newPath = filePath . replace ( "/" , "." ) . replace ( "\\" , "." ) ;
10+ const newPath = filePath . split ( / \/ | \\ / ) . join ( "." ) ;
1111 return `from datadog_lambda.wrapper import datadog_lambda_wrapper
1212from ${ newPath } import ${ method } as ${ method } _impl
1313${ method } = datadog_lambda_wrapper(${ method } _impl)`;
You can’t perform that action at this time.
0 commit comments