File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,28 @@ public function parseToJson()
54
54
}
55
55
56
56
file_put_contents ($ tmp_dir . '/index.apib ' , $ this ->apib );
57
+ if (!$ this ->drafter_location ()) {
58
+ $ fe = fopen ('php://stderr ' , 'w ' );
59
+ fwrite ($ fe , "Drafter was not installed! \n" );
60
+ exit (1 );
61
+ }
57
62
58
- system ( ' /usr/local/bin/drafter ' . $ tmp_dir . '/index.apib -f json > ' . $ tmp_dir . '/index.json 2> /dev/null ' );
63
+ shell_exec ( $ this -> drafter_location (). ' ' . $ tmp_dir . '/index.apib -f json -o ' . $ tmp_dir . '/index.json 2> /dev/null ' );
59
64
$ this ->json = file_get_contents ($ tmp_dir . '/index.json ' );
60
65
return $ this ->apib ;
61
66
}
62
67
68
+ /**
69
+ * Return drafter location if found
70
+ *
71
+ * @return bool|string
72
+ */
73
+ function drafter_location () {
74
+ $ returnVal = shell_exec ('which drafter 2> /dev/null ' );
75
+ $ returnVal = preg_replace ('/^\s+|\n|\r|\s+$/m ' , '' , $ returnVal );
76
+ return (empty ($ returnVal ) ? FALSE : $ returnVal );
77
+ }
78
+
63
79
/**
64
80
* JSON representation
65
81
*
You can’t perform that action at this time.
0 commit comments