Skip to content

Commit

Permalink
Merge pull request #43220 from gayaldassanayake/watch-help
Browse files Browse the repository at this point in the history
Add the help flag for bal run --watch
  • Loading branch information
azinneera authored Aug 2, 2024
2 parents 50eaace + 0cbc5f3 commit 0fc18a7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ OPTIONS
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.

--watch
[Experimental] Automatically re-run Ballerina service projects upon file
changes.


ARGUMENTS
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public DocumentId documentId(Path file) {
}
}
}
throw new ProjectException("provided path does not belong to the project");
throw new ProjectException("'" + file.toString() + "' does not belong to the current project");
}

private boolean isFilePathInProject(Path filepath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Project loadProject(Path path, ProjectEnvironmentBuilder projectEn
}

if (!ProjectPaths.isBalFile(absFilePath)) {
throw new ProjectException("provided path is not a valid Ballerina source file");
throw new ProjectException("'" + absFilePath + "' is not a valid Ballerina source file");
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Project duplicate() {
public DocumentId documentId(Path file) {
if (!this.sourceRoot.toAbsolutePath().normalize().toString().equals(
file.toAbsolutePath().normalize().toString())) {
throw new ProjectException("provided path does not belong to the project");
throw new ProjectException("'" + file + "' does not belong to the current project");
}
return this.currentPackage().getDefaultModule().documentIds().iterator().next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public static void validateBuildProjectDirPath(Path projectDirPath) {
}

if (ProjectUtils.findProjectRoot(projectDirPath.toAbsolutePath().getParent()) != null) {
throw new ProjectException("Provided path is already within a Ballerina package: " + projectDirPath);
throw new ProjectException("'" + projectDirPath + "' is already within a Ballerina package");
}

checkReadPermission(projectDirPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ProjectPaths {
public static Path packageRoot(Path filepath) throws ProjectException {
// check if the file exists
if (!Files.exists(filepath)) {
throw new ProjectException("provided path does not exist:" + filepath);
throw new ProjectException("'" + filepath + "'" + " does not exist");
}

if (Files.isDirectory(filepath)) {
Expand All @@ -62,7 +62,7 @@ public static Path packageRoot(Path filepath) throws ProjectException {

// check if the file is a regular file
if (!Files.isRegularFile(filepath)) {
throw new ProjectException("provided path is not a regular file: " + filepath);
throw new ProjectException("'" + filepath + "'" + " is not a regular file");
}

// Check if the file is inside a Ballerina package directory
Expand All @@ -79,7 +79,7 @@ public static Path packageRoot(Path filepath) throws ProjectException {
}

if (!isBalFile(filepath)) {
throw new ProjectException("provided path is not a valid Ballerina source file: " + filepath);
throw new ProjectException("'" + filepath + "' is not a valid Ballerina source file");
}

// check if the file is a source file in the default module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ public void testLoadBallerinaProjectInProject() {
TestUtils.loadBuildProject(projectPath);
Assert.fail("expected an invalid project exception");
} catch (ProjectException e) {
Assert.assertTrue(e.getMessage().contains("Provided path is already within a Ballerina package: " +
projectPath));
Assert.assertEquals(e.getMessage(), "'" + projectPath + "' is already within a Ballerina package");
}
}

Expand Down Expand Up @@ -838,7 +837,7 @@ public void testAccessNonExistingDocument() {
DocumentId oldDocumentId = buildProject.documentId(filePath); // get the document ID
Assert.fail();
} catch (ProjectException e) {
Assert.assertTrue(e.getMessage().contains("provided path does not belong to the project"));
Assert.assertTrue(e.getMessage().contains("'" + filePath + "' does not belong to the current project"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ public void testLoadBalaProjectByNonBalFile() {
project = TestUtils.loadProject(projectPath);
Assert.fail("project loading with a non-bal file is expected to fail");
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("provided path is not a valid Ballerina source file"));
Assert.assertEquals(e.getMessage(), "'" + projectPath.toAbsolutePath() +
"' is not a valid Ballerina source file");
}
}

Expand Down

0 comments on commit 0fc18a7

Please sign in to comment.