Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow custom manifest file, as well as json format.

  • Loading branch information...
commit 77fad131702f660dcdfac29284571cfd3f8b16dd 1 parent 9bf0e93
@timwienk timwienk authored
Showing with 22 additions and 4 deletions.
  1. +1 −1  packager
  2. +21 −3 packager.php
View
2  packager
@@ -18,7 +18,7 @@ switch ($command){
$folder = array_shift($argv);
$pkg = new Packager($folder);
$name = $pkg->get_package_name();
- $path = $pkg->get_package_path();
+ $path = $pkg->get_package_manifest();
$packages[$name] = $path;
View
24 packager.php
@@ -21,10 +21,27 @@ public function __construct($package_paths){
}
private function parse_manifest($package_path){
- $package_path = preg_replace('/\/$/', '', $package_path) . '/';
- $manifest = YAML::decode_file($package_path . 'package.yml');
+ if (is_file($package_path)){
+ $manifest_path = $package_path;
+ $pathinfo = pathinfo($package_path);
+ $package_path = $pathinfo['dirname'] . '/';
+ $manifest_format = $pathinfo['extension'];
+ } else {
+ $package_path = preg_replace('/\/$/', '', $package_path) . '/';
+ $manifest_path = $package_path . 'package.yml';
+ $manifest_format = 'yml';
+ }
+
+ switch ($manifest_format){
+ case 'json':
+ $manifest = json_decode(file_get_contents($manifest_path), true);
+ break;
+
+ default:
+ $manifest = YAML::decode_file($manifest_path);
+ }
- if (empty($manifest)) throw new Exception("package.yml not found in $package_path, or unable to parse manifest.");
+ if (empty($manifest)) throw new Exception(basename($manifest_path) . " not found in $package_path, or unable to parse manifest.");
$package_name = $manifest['name'];
@@ -33,6 +50,7 @@ private function parse_manifest($package_path){
if (array_has($this->manifests, $package_name)) return;
$manifest['path'] = $package_path;
+ $manifest['manifest'] = $manifest_path;
$this->manifests[$package_name] = $manifest;
Please sign in to comment.
Something went wrong with that request. Please try again.