Code review comment: Shall we move/merge this line with 103?

Code under review:
public void execute() {
        if (helpFlag) {
            String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(parentCmdParser, "build");
            outStream.println(commandUsageInfo);
            return;
        }

        if (argList != null && argList.size() > 1) {
            throw LauncherUtils.createUsageException("too many arguments");
        }

        
        Path currentDir = Paths.get(System.getProperty(USER_DIR));
        if (argList == null || argList.size() == 0) {
            
            BuilderUtils.compileWithTestsAndWrite(currentDir, offline, lockEnabled, skiptests);
        } else {
            
            String targetFileName;
            String pkgName = argList.get(0);
            if (pkgName.endsWith("/")) {
                pkgName = pkgName.substring(0, pkgName.length() - 1);
            }
            if (outputFileName != null && !outputFileName.isEmpty()) {
                targetFileName = outputFileName;
            } else {
                targetFileName = pkgName;
            }

            Path sourceFilePath = Paths.get(pkgName);
            Path resolvedFullPath = currentDir.resolve(sourceFilePath);
            
            if (Files.isRegularFile(resolvedFullPath) &&
                    sourceFilePath.toString().endsWith(BLangConstants.BLANG_SRC_FILE_SUFFIX) &&
                    !RepoUtils.hasProjectRepo(currentDir)) {
                
                
                
                
                
                targetFileName = getTargetFileName(Paths.get(targetFileName));

                
                Path parent = resolvedFullPath.getParent();
                currentDir = parent != null ? parent : currentDir;

                
                Path resolvedFileName = resolvedFullPath.getFileName();
                pkgName = resolvedFileName != null ? resolvedFileName.toString() : pkgName;

            } else if (Files.isDirectory(currentDir)) { 
                
                if (Files.isDirectory(resolvedFullPath) && !RepoUtils.hasProjectRepo(currentDir)) {
                    outStream.println("error: do you mean to build the ballerina package as a project? If so run" +
                                              " ballerina init to make it a project with a .ballerina directory");
                    return;
                }
            } else {
                
                outStream.println("error: invalid Ballerina source path, it should either be a directory or a" +
                                          "file  with a \'" + BLangConstants.BLANG_SRC_FILE_SUFFIX + "\' extension");
                return;
            }
            BuilderUtils.compileWithTestsAndWrite(currentDir, pkgName, targetFileName, buildCompiledPkg,
                                                  offline, lockEnabled, skiptests);
        }
        Runtime.getRuntime().exit(0);
    }

Line commented on: !RepoUtils.hasProjectRepo(currentDir)) {

Revised code:
public void execute() {
        if (helpFlag) {
            String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(parentCmdParser, "build");
            outStream.println(commandUsageInfo);
            return;
        }

        if (argList != null && argList.size() > 1) {
            throw LauncherUtils.createUsageException("too many arguments");
        }

        
        Path sourceRootPath = Paths.get(System.getProperty(USER_DIR));
        if (argList == null || argList.size() == 0) {
            
            BuilderUtils.compileWithTestsAndWrite(sourceRootPath, offline, lockEnabled, skiptests);
        } else {
            
            String targetFileName;
            String pkgName = argList.get(0);
            if (pkgName.endsWith("/")) {
                pkgName = pkgName.substring(0, pkgName.length() - 1);
            }
            if (outputFileName != null && !outputFileName.isEmpty()) {
                targetFileName = outputFileName;
            } else {
                targetFileName = pkgName;
            }

            Path sourcePath = Paths.get(pkgName);
            Path resolvedFullPath = sourceRootPath.resolve(sourcePath);
            
            if (Files.isRegularFile(resolvedFullPath) &&
                    sourcePath.toString().endsWith(BLangConstants.BLANG_SRC_FILE_SUFFIX) &&
                    !RepoUtils.hasProjectRepo(sourceRootPath)) {
                
                
                
                
                
                targetFileName = getTargetFileName(Paths.get(targetFileName));

                
                Path parent = resolvedFullPath.getParent();
                sourceRootPath = parent != null ? parent : sourceRootPath;

                
                Path resolvedFileName = resolvedFullPath.getFileName();
                pkgName = resolvedFileName != null ? resolvedFileName.toString() : pkgName;

            } else if (Files.isDirectory(sourceRootPath)) { 
                
                if (Files.isDirectory(resolvedFullPath) && !RepoUtils.hasProjectRepo(sourceRootPath)) {
                    outStream.println("error: do you mean to build the ballerina package as a project? If so run" +
                                              " ballerina init to make it a project with a .ballerina directory");
                    return;
                }
            } else {
                
                outStream.println("error: invalid Ballerina source path, it should either be a directory or a" +
                                          "file  with a \'" + BLangConstants.BLANG_SRC_FILE_SUFFIX + "\' extension");
                return;
            }
            BuilderUtils.compileWithTestsAndWrite(sourceRootPath, pkgName, targetFileName, buildCompiledPkg,
                                                  offline, lockEnabled, skiptests);
        }
        Runtime.getRuntime().exit(0);
    }