Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Or-Geva committed Oct 19, 2023
1 parent af5bf2d commit 378affc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> = new Set<string>();
Expand Down
21 changes: 13 additions & 8 deletions src/main/utils/goUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -251,6 +257,5 @@ export class GoUtils {
}
}
return false;
};

}
}
}
8 changes: 5 additions & 3 deletions src/test/tests/goUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down

0 comments on commit 378affc

Please sign in to comment.