From 321abe3d213405bfe3349aa65fd42e6e456a1740 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 6 Apr 2019 01:32:44 +0200 Subject: [PATCH] Update internal Node.js function call This updates the call to _resolveLookupPaths. It returns a string by default since Node.js v8 when called with a third truthy argument. The backwards compatible return value should change soon, so detect what return type is used and handle both cases. Refs: nodejs/node#26983 --- build/get-nodejs/get-nodejs-debug.js | 6 +++++- build/get-nodejs/get-nodejs.js | 6 +++++- build/yui-nodejs/yui-nodejs-debug.js | 6 +++++- build/yui-nodejs/yui-nodejs.js | 6 +++++- src/get/js/get-nodejs.js | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/build/get-nodejs/get-nodejs-debug.js b/build/get-nodejs/get-nodejs-debug.js index 6e476881710..7d21f9518a1 100644 --- a/build/get-nodejs/get-nodejs-debug.js +++ b/build/get-nodejs/get-nodejs-debug.js @@ -106,7 +106,11 @@ YUI.add('get', function (Y, NAME) { } else { try { // Try to resolve paths relative to the module that required yui. - url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); + var path = Module._resolveLookupPaths(url, module.parent.parent, true); + + url = Module._findPath(url, + (path.length !== 2 || typeof path[1] !== 'object') ? path : path[1] + ); if (Y.config.useSync) { //Needs to be in useSync diff --git a/build/get-nodejs/get-nodejs.js b/build/get-nodejs/get-nodejs.js index 8e07eed9c34..e6441e21902 100644 --- a/build/get-nodejs/get-nodejs.js +++ b/build/get-nodejs/get-nodejs.js @@ -102,7 +102,11 @@ YUI.add('get', function (Y, NAME) { } else { try { // Try to resolve paths relative to the module that required yui. - url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); + var path = Module._resolveLookupPaths(url, module.parent.parent, true); + + url = Module._findPath(url, + (path.length !== 2 || typeof path[1] !== 'object') ? path : path[1] + ); if (Y.config.useSync) { //Needs to be in useSync diff --git a/build/yui-nodejs/yui-nodejs-debug.js b/build/yui-nodejs/yui-nodejs-debug.js index c2aaced1232..938f8656697 100644 --- a/build/yui-nodejs/yui-nodejs-debug.js +++ b/build/yui-nodejs/yui-nodejs-debug.js @@ -4383,7 +4383,11 @@ YUI.add('get', function (Y, NAME) { } else { try { // Try to resolve paths relative to the module that required yui. - url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); + var path = Module._resolveLookupPaths(url, module.parent.parent, true); + + url = Module._findPath(url, + (path.length !== 2 || typeof path[1] !== 'object') ? path : path[1] + ); if (Y.config.useSync) { //Needs to be in useSync diff --git a/build/yui-nodejs/yui-nodejs.js b/build/yui-nodejs/yui-nodejs.js index ecbd1875100..d66ea3c7f6e 100644 --- a/build/yui-nodejs/yui-nodejs.js +++ b/build/yui-nodejs/yui-nodejs.js @@ -4132,7 +4132,11 @@ YUI.add('get', function (Y, NAME) { } else { try { // Try to resolve paths relative to the module that required yui. - url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); + var path = Module._resolveLookupPaths(url, module.parent.parent, true); + + url = Module._findPath(url, + (path.length !== 2 || typeof path[1] !== 'object') ? path : path[1] + ); if (Y.config.useSync) { //Needs to be in useSync diff --git a/src/get/js/get-nodejs.js b/src/get/js/get-nodejs.js index cb148135733..0388803c06a 100644 --- a/src/get/js/get-nodejs.js +++ b/src/get/js/get-nodejs.js @@ -104,7 +104,11 @@ } else { try { // Try to resolve paths relative to the module that required yui. - url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); + var path = Module._resolveLookupPaths(url, module.parent.parent, true); + + url = Module._findPath(url, + (path.length !== 2 || typeof path[1] !== 'object') ? path : path[1] + ); if (Y.config.useSync) { //Needs to be in useSync