From 378affc197032f62ed9316186ef12f0c6d7b24a8 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Thu, 19 Oct 2023 17:21:41 +0300 Subject: [PATCH] format --- .../dependenciesRoot/goTree.ts | 2 +- src/main/utils/goUtils.ts | 21 ++++++++++++------- src/test/tests/goUtils.test.ts | 8 ++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts index e9b727a8..2ac42b8a 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts @@ -92,7 +92,7 @@ export class GoTreeNode extends RootNode { } //Filter out go min version that is written in go mod e.g. go@v1.19 - directDependenciesGeneralInfos = directDependenciesGeneralInfos.filter(generalInfo => !generalInfo.artifactId.startsWith("go@")) + directDependenciesGeneralInfos = directDependenciesGeneralInfos.filter(generalInfo => !generalInfo.artifactId.startsWith('go@')); // Create a set of packages that are actually in use in the project let goListPackages: Set = new Set(); diff --git a/src/main/utils/goUtils.ts b/src/main/utils/goUtils.ts index ac05a87b..e194b9d0 100644 --- a/src/main/utils/goUtils.ts +++ b/src/main/utils/goUtils.ts @@ -204,15 +204,21 @@ export class GoUtils { * @param targetDir - Target directory to copy relevant files to. * @param goModAbsDir - Path to the location of the gomod-absolutizer tool. */ - public static prepareProjectWorkspace(sourceDir: string, targetDir: string, goModAbsDir: string, logManager: LogManager, executeCmdFunction: (goModPath: string, sourceDir: string, goModAbsDir: string) => void) { + public static prepareProjectWorkspace( + sourceDir: string, + targetDir: string, + goModAbsDir: string, + logManager: LogManager, + executeCmdFunction: (goModPath: string, sourceDir: string, goModAbsDir: string) => void + ) { logManager.logMessage('copy go workspace from' + sourceDir + ', to' + targetDir, 'DEBUG'); - walkdir.find(sourceDir, { follow_symlinks: false, sync: true }, function (curPath: string, stat: fs.Stats) { + walkdir.find(sourceDir, { follow_symlinks: false, sync: true }, function(curPath: string, stat: fs.Stats) { let destPath: string = path.resolve(targetDir, path.relative(sourceDir, curPath)); if (stat.isDirectory()) { if (GoUtils.shouldSkipDirectory(curPath, '.git', 'testdata', '.idea', '.vscode')) { this.ignore(curPath); - return + return; } if (!(curPath === sourceDir)) { // Skip subdirectories with go.mod files. @@ -231,10 +237,10 @@ export class GoUtils { } if (curPath.endsWith('_test.go')) { - return + return; } - logManager.logMessage('copying ' + curPath + ' to ' + destPath, 'DEBUG') + logManager.logMessage('copying ' + curPath + ' to ' + destPath, 'DEBUG'); fs.copySync(curPath, destPath); // The root go.mod file is copied and relative path in "replace" are resolved to absolute paths. @@ -251,6 +257,5 @@ export class GoUtils { } } return false; - }; - -} \ No newline at end of file + } +} diff --git a/src/test/tests/goUtils.test.ts b/src/test/tests/goUtils.test.ts index e10cdbaf..a69c86f2 100644 --- a/src/test/tests/goUtils.test.ts +++ b/src/test/tests/goUtils.test.ts @@ -238,10 +238,12 @@ describe('Go Utils Tests', async () => { const sourceDir: string = path.join(tmpDir, 'prepareProjectWorkspace'); const targetDir: string = path.join(tmpDir, 'tmpDir'); - // Call the function with test directories - GoUtils.prepareProjectWorkspace(sourceDir, targetDir, '', logManager, () => { return }); + + GoUtils.prepareProjectWorkspace(sourceDir, targetDir, '', logManager, () => { + return; + }); + - // Assert that the .git directory in the source was skipped assert.isFalse(fs.existsSync(targetDir), 'The target directory should not exist since all files should be excluded'); }); });