42_npmjs: add JSON preference order

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@19398 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-05-18 10:53:29 +00:00
parent a758741bee
commit 71e065c46b

View File

@ -37,37 +37,32 @@ use Data::Dumper;
# Run before module compilation # Run before module compilation
BEGIN { BEGIN {
# JSON preference order
$ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
# Import from main:: # Import from main::
GP_Import( GP_Import(
qw( qw(
readingsSingleUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsBeginUpdate
readingsEndUpdate
ReadingsTimestamp
defs
modules
Log3
Debug
DoTrigger
CommandAttr
attr attr
AttrVal AttrVal
ReadingsVal CommandAttr
Value Debug
IsDisabled defs
deviceEvents deviceEvents
init_done DoTrigger
gettimeofday
InternalTimer
RemoveInternalTimer
FW_webArgs FW_webArgs
gettimeofday
init_done
InternalTimer
IsDisabled
Log3
modules
readingsBeginUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsEndUpdate
readingsSingleUpdate
ReadingsTimestamp
ReadingsVal
RemoveInternalTimer
Value
) )
); );
} }
@ -85,6 +80,12 @@ if ($@) {
# try to use JSON wrapper # try to use JSON wrapper
# for chance of better performance # for chance of better performance
eval { eval {
# JSON preference order
local $ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
require JSON; require JSON;
import JSON qw( decode_json encode_json ); import JSON qw( decode_json encode_json );
1; 1;
@ -473,7 +474,7 @@ sub Set($$@) {
if ( !defined( $hash->{".fhem"}{npm}{nodejsversions} ) ) { if ( !defined( $hash->{".fhem"}{npm}{nodejsversions} ) ) {
$list = $list =
"install:nodejs-v11,nodejs-v10,nodejs-v8,nodejs-v6 statusRequest:noArg"; "install:nodejs-v12,nodejs-v10,nodejs-v8,nodejs-v6 statusRequest:noArg";
} }
else { else {
$list = "outdated:noArg"; $list = "outdated:noArg";
@ -896,7 +897,7 @@ sub ExecuteNpmCommand($) {
} }
my $global = '-g '; my $global = '-g ';
my $sudo = 'sudo -H -n '; my $sudo = 'sudo -n ';
if ( $cmd->{npmglobal} eq '0' ) { if ( $cmd->{npmglobal} eq '0' ) {
$global = ''; $global = '';
@ -958,9 +959,11 @@ sub ExecuteNpmCommand($) {
$npm->{npminstall} = $npm->{npminstall} =
$cmdPrefix $cmdPrefix
. 'echo n | if [ -z "$(node --version 2>/dev/null)" ]; then' . 'echo n | if [ -z "$(node --version 2>/dev/null)" ]; then'
. ' sh -c "curl -sSL https://deb.nodesource.com/setup_' . ' sh -c "( curl -fsSL https://deb.nodesource.com/setup_'
. $1 . $1
. '.x | DEBIAN_FRONTEND=noninteractive sudo -n bash - >/dev/null 2>&1" 2>&1 &&' . '.x 2>/dev/null || wget -qO- https://deb.nodesource.com/setup_'
. $1
. '.x 2>/dev/null ) | DEBIAN_FRONTEND=noninteractive sudo -n bash - >/dev/null 2>&1" 2>&1 &&'
. ' sh -c "DEBIAN_FRONTEND=noninteractive sudo -n apt-get install -qqy nodejs >/dev/null 2>&1" 2>&1; ' . ' sh -c "DEBIAN_FRONTEND=noninteractive sudo -n apt-get install -qqy nodejs >/dev/null 2>&1" 2>&1; '
. 'fi; ' . 'fi; '
. 'node -e "console.log(JSON.stringify(process.versions));" 2>&1' . 'node -e "console.log(JSON.stringify(process.versions));" 2>&1'
@ -1825,7 +1828,7 @@ sub ToDay() {
"abstract": "Modul zur Bedienung der Node.js Installation und Updates" "abstract": "Modul zur Bedienung der Node.js Installation und Updates"
} }
}, },
"version": "v1.1.0", "version": "v1.1.1",
"release_status": "stable", "release_status": "stable",
"author": [ "author": [
"Julian Pawlowski <julian.pawlowski@gmail.com>" "Julian Pawlowski <julian.pawlowski@gmail.com>"