daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getRegistry() {
  2.   let globalNpmrc, localNpmrc, npmrc;
  3.   let token = process.env.NPM_TOKEN
  4.  
  5.   try {
  6.     globalNpmrc = fs.readFileSync(
  7.       path.join(home, '.npmrc'), { encoding: 'utf8'}
  8.     )
  9.   } catch(err) {}
  10.  
  11.   try {
  12.     localNpmrc = fs.readFileSync(
  13.       path.join(appRoot.path, '.npmrc'),
  14.       { encoding: 'utf8'}  
  15.     )  
  16.   } catch(err) {}
  17.  
  18.   if(
  19.     !globalNpmrc &&
  20.     !localNpmrc
  21.   ) {
  22.     npmrc = '//' + defaultRegistry + '/:_authToken=' + token
  23.     fs.writeFileSync(
  24.       path.join(appRoot.path, '.npmrc'),
  25.       npmrc,
  26.       { encoding: 'utf8'}
  27.     )
  28.     return defaultRegistry
  29.   }
  30.  
  31.   if(localNpmrc) npmrc = parseNpmrc(localNpmrc)
  32.   else npmrc = parseNpmrc(globalNpmrc)
  33.   let [registry, ...rest] = Object.keys(npmrc.registries)
  34.   return registry;
  35. }
RAW Paste Data
Top