You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the working directory of Web Test Runner and its parent directories do not contain a package.json file the getPackageType function will loop forever.
This happens because path.resolve('/', '..') will return / without throwing any errors, hence the currentPath variable will keep the same value and the loop will never exit.
Suggested Fix
Add a check that the path has changed when the parent path is resolved.
asyncfunctiongetPackageType(basedir){letcurrentPath=basedir;try{while(awaitfileExists(currentPath)){constpkgJsonPath=path.join(currentPath,'package.json');if(awaitfileExists(pkgJsonPath)){constpkgJsonString=awaitfs.readFile(pkgJsonPath,{encoding: 'utf-8'});constpkgJson=JSON.parse(pkgJsonString);returnpkgJson.type||'commonjs';}constoldPath=currentPath;currentPath=path.resolve(oldPath,'..');if(currentPath===oldPath){return'commonjs';}}}catch(e){// don't log any error}return'commonjs';}
The text was updated successfully, but these errors were encountered:
If the working directory of Web Test Runner and its parent directories do not contain a package.json file the
getPackageType
function will loop forever.This happens because
path.resolve('/', '..')
will return/
without throwing any errors, hence thecurrentPath
variable will keep the same value and the loop will never exit.Suggested Fix
Add a check that the path has changed when the parent path is resolved.
The text was updated successfully, but these errors were encountered: