UNPKG

preferred-node-version

Version:

Get the preferred Node.js version of a project or user

30 lines (22 loc) 581 B
import{getVersionEnvVariable}from"./env.js"; import{loadVersionFile}from"./load.js"; import{getFilePath}from"./path.js"; export const findVersion=async({cwd,globalOpt,files})=>{ const{filePath,rawVersion}=await getVersionFile({ cwd, globalOpt, files }); if(rawVersion!==undefined){ return{filePath,rawVersion} } return getVersionEnvVariable() }; const getVersionFile=async({cwd,globalOpt,files})=>{ const filePath=await getFilePath({cwd,globalOpt,files}); if(filePath===undefined){ return{} } const rawVersion=await loadVersionFile(filePath); return{filePath,rawVersion} };