function moment_get_package_version in Moment.js 7.2
Same name and namespace in other branches
- 8.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.
1 call to moment_get_package_version()
- moment_get_library_version in ./
moment.module - Library info "version callback".
File
- ./
moment.module, line 200 - Moment.js integration.
Code
function moment_get_package_version($library_path) {
static $versions = [];
if (!$library_path) {
return FALSE;
}
if (!isset($versions[$library_path])) {
$versions[$library_path] = FALSE;
if (is_readable("{$library_path}/package.json")) {
$package = drupal_json_decode(file_get_contents("{$library_path}/package.json"));
if ($package && !empty($package['version'])) {
$versions[$library_path] = $package['version'];
}
}
}
return $versions[$library_path];
}