diff --git a/composer.json b/composer.json index 15fd275..4c9f7c0 100644 --- a/composer.json +++ b/composer.json @@ -1,33 +1,34 @@ { - "name": "davidbadura/taskwarrior", - "description": "a php lib for taskwarrior", - "keywords": [ - "task", - "taskwarrior" - ], - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "David Badura", - "email": "d.badura@gmx.de" + "name": "davidbadura/taskwarrior", + "description": "a php lib for taskwarrior", + "keywords": [ + "task", + "taskwarrior" + ], + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "David Badura", + "email": "d.badura@gmx.de" + } + ], + "require": { + "php": ">=5.4", + "symfony/process": "~2.3", + "jms/serializer": "0.16.*", + "symfony/filesystem": "~2.3", + "nesbot/carbon": "~1.14", + "doctrine/collections": "~1.3", + "webmozart/path-util": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "symfony/var-dumper": "~2.6" + }, + "autoload": { + "psr-4": { + "DavidBadura\\Taskwarrior\\": "src" + } } - ], - "require": { - "php": ">=5.4", - "symfony/process": "~2.3", - "jms/serializer": "0.16.*", - "symfony/filesystem": "~2.3", - "nesbot/carbon": "~1.14", - "doctrine/collections": "~1.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "symfony/var-dumper": "~2.6" - }, - "autoload": { - "psr-4": { - "DavidBadura\\Taskwarrior\\": "src" - } - } } diff --git a/src/Taskwarrior.php b/src/Taskwarrior.php index 37d0354..b643b71 100644 --- a/src/Taskwarrior.php +++ b/src/Taskwarrior.php @@ -7,6 +7,7 @@ use DavidBadura\Taskwarrior\Exception\CommandException; use DavidBadura\Taskwarrior\Exception\TaskwarriorException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; +use Webmozart\PathUtil\Path; /** * @author David Badura @@ -42,11 +43,11 @@ class Taskwarrior */ public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task') { - $this->bin = $bin; + $this->bin = Path::canonicalize($bin); $this->rcOptions = array_merge( array( - 'rc:' . $taskrc, - 'rc.data.location=' . $taskData, + 'rc:' . Path::canonicalize($taskrc), + 'rc.data.location=' . Path::canonicalize($taskData), 'rc.json.array=true', 'rc.confirmation=no', ), @@ -184,7 +185,7 @@ class Taskwarrior $filter = array_filter((array)$filter, 'trim'); if ($filter) { - foreach($filter as $f) { + foreach ($filter as $f) { $parts[] = "( " . $f . " )"; } } @@ -296,7 +297,7 @@ class Taskwarrior */ private function createCommandLine(array $parts) { - $parts = array_map(function($part) { + $parts = array_map(function ($part) { return "'" . str_replace("'", "'\\''", $part) . "'"; }, $parts);