Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #107 from Trivadis/bugfix/issue-106-param-with-spaces
Browse files Browse the repository at this point in the history
Bugfix/issue #106 Cannot process RootPath with spaces
  • Loading branch information
PhilippSalvisberg committed May 22, 2021
2 parents 59bae2d + d804653 commit 91397c0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sqlcl/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ var run = function(args) {
}

var getArgs = function(cmdLine) {
var p = javaPattern.compile('("[^"]*")|([^ ]+)');
var p = javaPattern.compile('("([^"]*)")|([^ ]+)');
var m = p.matcher(cmdLine.trim());
var args = [];
while (m.find()) {
args.push(m.group());
args.push(m.group(3) != null ? m.group(3) : m.group(2));
}
return args;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.trivadis.plsql.formatter.sqlcl.tests;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TvdFormatPathWithSpaceTest extends AbstractSqlclTest {

@Before
public void registerCommandBeforeTest() {
runScript("--register");
byteArrayOutputStream.reset();
}

@Test
public void path_with_spaces() throws IOException {
final Path myFilesDir = Files.createTempDirectory("my files");
final String actual = runCommand("tvdformat \"" + myFilesDir.toAbsolutePath() + "\"");
// directory is empty, no files processed
Assert.assertTrue(actual.trim().isEmpty());
}

}

0 comments on commit 91397c0

Please sign in to comment.