Skip to content

Commit

Permalink
Added support to release date
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed May 10, 2017
1 parent 102d0aa commit c67482d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Converter/BowerPackageConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected function getMapKeys()
'description' => 'description',
'keywords' => 'keywords',
'license' => 'license',
'time' => 'time',
'bin' => 'bin',
);
}
Expand Down
1 change: 1 addition & 0 deletions Converter/NpmPackageConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function getMapKeys()
'keywords' => 'keywords',
'homepage' => 'homepage',
'license' => 'license',
'time' => 'time',
'author' => array('authors', function ($value) {
return NpmPackageUtil::convertAuthor($value);
}),
Expand Down
9 changes: 9 additions & 0 deletions Repository/NpmRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Composer\Package\Loader\ArrayLoader;
use Composer\Repository\ArrayRepository;
use Fxp\Composer\AssetPlugin\Converter\NpmPackageUtil;
use Fxp\Composer\AssetPlugin\Converter\PackageUtil;
use Fxp\Composer\AssetPlugin\Exception\InvalidCreateRepositoryException;

/**
Expand Down Expand Up @@ -83,6 +84,14 @@ protected function createVcsRepositoryConfig(array $data, $registryName = null)
{
$type = isset($data['repository']['type']) ? $data['repository']['type'] : 'vcs';

// Add release date in $packageConfigs
if (isset($data['versions']) && isset($data['time'])) {
$time = $data['time'];
array_walk($data['versions'], function (&$packageConfigs, $version) use ($time) {
PackageUtil::convertStringKey($time, $version, $packageConfigs, 'time');
});
}

return array(
'type' => $this->assetType->getName().'-'.$type,
'url' => $this->getVcsRepositoryUrl($data, $registryName),
Expand Down
3 changes: 3 additions & 0 deletions Tests/Repository/NpmRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function testWatProvidesWithoutRepositoryUrl()
),
),
),
'time' => array(
'1.0.0' => '2016-09-20T13:48:47.730Z',
),
))));

$this->assertCount(0, $this->rm->getRepositories());
Expand Down

0 comments on commit c67482d

Please sign in to comment.