add path util
This commit is contained in:
parent
7019d21a71
commit
6b4d1ae4e8
|
@ -1,33 +1,34 @@
|
||||||
{
|
{
|
||||||
"name": "davidbadura/taskwarrior",
|
"name": "davidbadura/taskwarrior",
|
||||||
"description": "a php lib for taskwarrior",
|
"description": "a php lib for taskwarrior",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"task",
|
"task",
|
||||||
"taskwarrior"
|
"taskwarrior"
|
||||||
],
|
],
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "David Badura",
|
"name": "David Badura",
|
||||||
"email": "d.badura@gmx.de"
|
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use DavidBadura\Taskwarrior\Exception\CommandException;
|
||||||
use DavidBadura\Taskwarrior\Exception\TaskwarriorException;
|
use DavidBadura\Taskwarrior\Exception\TaskwarriorException;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
use Webmozart\PathUtil\Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author David Badura <d.a.badura@gmail.com>
|
* @author David Badura <d.a.badura@gmail.com>
|
||||||
|
@ -42,11 +43,11 @@ class Taskwarrior
|
||||||
*/
|
*/
|
||||||
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
|
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
|
||||||
{
|
{
|
||||||
$this->bin = $bin;
|
$this->bin = Path::canonicalize($bin);
|
||||||
$this->rcOptions = array_merge(
|
$this->rcOptions = array_merge(
|
||||||
array(
|
array(
|
||||||
'rc:' . $taskrc,
|
'rc:' . Path::canonicalize($taskrc),
|
||||||
'rc.data.location=' . $taskData,
|
'rc.data.location=' . Path::canonicalize($taskData),
|
||||||
'rc.json.array=true',
|
'rc.json.array=true',
|
||||||
'rc.confirmation=no',
|
'rc.confirmation=no',
|
||||||
),
|
),
|
||||||
|
@ -184,7 +185,7 @@ class Taskwarrior
|
||||||
$filter = array_filter((array)$filter, 'trim');
|
$filter = array_filter((array)$filter, 'trim');
|
||||||
|
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
foreach($filter as $f) {
|
foreach ($filter as $f) {
|
||||||
$parts[] = "( " . $f . " )";
|
$parts[] = "( " . $f . " )";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,7 @@ class Taskwarrior
|
||||||
*/
|
*/
|
||||||
private function createCommandLine(array $parts)
|
private function createCommandLine(array $parts)
|
||||||
{
|
{
|
||||||
$parts = array_map(function($part) {
|
$parts = array_map(function ($part) {
|
||||||
return "'" . str_replace("'", "'\\''", $part) . "'";
|
return "'" . str_replace("'", "'\\''", $part) . "'";
|
||||||
}, $parts);
|
}, $parts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue