@@ -224,12 +224,13 @@ function isResponseOk(response: IncomingMessage): boolean {
224
224
)
225
225
}
226
226
227
- function resolveBasePath ( pathsRelativeTo = '.' ) : string {
227
+ function resolveAbsPaths ( filepaths : string [ ] , pathsRelativeTo = '.' ) : string [ ] {
228
228
// Node's path.resolve will process path segments from right to left until
229
229
// it creates a valid absolute path. So if `pathsRelativeTo` is an absolute
230
230
// path, process.cwd() is not used, which is the common expectation. If none
231
231
// of the paths resolve then it defaults to process.cwd().
232
- return path . resolve ( process . cwd ( ) , pathsRelativeTo )
232
+ const basePath = path . resolve ( process . cwd ( ) , pathsRelativeTo )
233
+ return filepaths . map ( p => path . resolve ( basePath , p ) )
233
234
}
234
235
235
236
/**
@@ -459,8 +460,7 @@ export class SocketSdk {
459
460
filepaths : string [ ] ,
460
461
pathsRelativeTo = '.'
461
462
) : Promise < SocketSdkResultType < 'createDependenciesSnapshot' > > {
462
- const basePath = resolveBasePath ( pathsRelativeTo )
463
- const absFilepaths = filepaths . map ( p => path . join ( basePath , p ) )
463
+ const absFilepaths = resolveAbsPaths ( filepaths , pathsRelativeTo )
464
464
try {
465
465
const data = await getResponseJson (
466
466
await createUploadRequest (
@@ -482,8 +482,7 @@ export class SocketSdk {
482
482
filepaths : string [ ] ,
483
483
pathsRelativeTo : string = '.'
484
484
) : Promise < SocketSdkResultType < 'CreateOrgFullScan' > > {
485
- const basePath = resolveBasePath ( pathsRelativeTo )
486
- const absFilepaths = filepaths . map ( p => path . join ( basePath , p ) )
485
+ const absFilepaths = resolveAbsPaths ( filepaths , pathsRelativeTo )
487
486
try {
488
487
const data = await getResponseJson (
489
488
await createUploadRequest (
@@ -523,8 +522,7 @@ export class SocketSdk {
523
522
pathsRelativeTo : string = '.' ,
524
523
issueRules ?: Record < string , boolean >
525
524
) : Promise < SocketSdkResultType < 'createReport' > > {
526
- const basePath = resolveBasePath ( pathsRelativeTo )
527
- const absFilepaths = filepaths . map ( p => path . join ( basePath , p ) )
525
+ const absFilepaths = resolveAbsPaths ( filepaths , pathsRelativeTo )
528
526
try {
529
527
const data = await createUploadRequest (
530
528
this . #baseUrl,
0 commit comments