function moment_get_package_version in Moment.js 8.2
Same name and namespace in other branches
- 7.2 moment.module \moment_get_package_version()
Get the version number from package JSON.
Parameters
string $library_path: Directory.
Return value
string|false Version number.
File
- ./
moment.module, line 19 - Moment.js integration.
Code
function moment_get_package_version($library_path) {
static $versions = [];
if (!$library_path) {
return FALSE;
}
if (!isset($version[$library_path])) {
$versions[$library_path] = FALSE;
if (is_readable("{$library_path}/package.json")) {
$package = Json::decode(file_get_contents("{$library_path}/package.json"));
if ($package && !empty($package['version'])) {
$versions[$library_path] = $package['version'];
}
}
}
return $versions[$library_path];
}