Skip to content

Commit

Permalink
feat(utils): add getNodeModulePath utility
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed Apr 13, 2022
1 parent 927f06f commit a811a53
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,18 @@ export const isSASjsProject = async () => {
}
return false
}

export const getNodeModulePath = async (module: string): Promise<string> => {
const localPath = path.join(process.cwd(), 'node_modules', module)

if (await folderExists(localPath)) return localPath

const globalPath = path.join(
shelljs.exec(`npm root -g`, { silent: true }).stdout.replace(/\n/, ''),
module
)

if (await folderExists(globalPath)) return globalPath

return ''
}

0 comments on commit a811a53

Please sign in to comment.